3/18/2014

ColdFusion on Linux, Out Of Memory


if you get an "Out of Memory" error or "Too Many Files Open" error when running coldfusion on linux

it could be and is likely to be

/opt/coldfusion9/logs/cfserver.log

has grown to larger than 500 MB

especially long queries can trip the timeout limits set in the server settings and any monitoring you have turned on, exacerbating the problem by filling the log up even faster

on linux the cfserver.log file cannot be limited or rotated by the coldfusion process itself because it is attached to the standard out of the original process which spawn all the service threads

it is appropriate to use the native linux "logrotate" service

# man page logrotate

/usr/sbin/logrotate

/etc/logrotate.conf
/etc/logrotate.d

/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly

by default the logrotate service is called by the master logrotate cron task in /etc/cron.daily

it sources the /etc/logrotate.conf for global default behavior, which includes all of the files in the

/etc/logrotate.d directory

generally there is one file named after the service whose logs that file explains how to rotate

logrotate can truncate log files, or perform a service shutdown and restart, after copying and optionally compressing and emailing the log files

to run logrotate more often use

# crontab -e

with a custom task

0 * * * *  /usr/sbin/logrotate -f /etc/logrotate.d/coldfusion

to test a logrotate configuration file, force a premature logrotate

/usr/sbin/logrotate --force -f /etc/logrotate.d/coldfusion

logrotate can "decide" to rotate based on size, or by last time run as indicated by a files date stamp

you may try rotating the cfserver.log file by the logrotate "copytruncate" directive

you may try rotating the cfserver.log file by the "postrotate" command to stop and start

if you use the "postrotate" option it may not restart coldfusion with all of the environment variables

http://rachaelandtom.info/content/coldfusion-forgets-use-utf-8-files-after-logs-rotated

/opt/coldfusion9/logs/cfserver.log {
  missingok
  rotate 5
  size=250M
  compress
  postrotate
         /sbin/runuser -s /bin/bash root -c "export LANG=en_GB.UTF-8 ; 
/etc/init.d/coldfusion_9 restart"

 endscript

}