I have simple Rails app running on Jruby-1.0.1 on Tomcat 5 on Linux.
Every
10 days or so, it crashes because the process has too many open files. I
restarted my application two days ago, and this morning using lsof I see
that my process now has 126 file handles to the file production.log.
In catalina.out, I see a series of entries that look like this:
This is a red herring – it doesn’t have anything to do with the open
file issue.
The runtime number is always incremented by one and seems to correspond to
the number of file handles I have.
We probably have a bug here that the log finalizers are not running
and are not closing the files, but you might consider working around
this by not using the Rails log files at all. For example, 1 shows
how we’re doing this, by redirecting Rails logger output to the
servlet context log, which would end up in catalina.out. Just paste
that code at the end of your environment.rb.
My output is now being logged to catalina.out, but Rails is still
creating
the file handle to its production.log. Even if I have the Logger point
directly to catalina.out, I’m still going to get the dangling file
handle,
right?
Is there an end of request hook I where I can close the logger object
myself?
My output is now being logged to catalina.out, but Rails is still creating
the file handle to its production.log. Even if I have the Logger point
directly to catalina.out, I’m still going to get the dangling file handle,
right?
Is there an end of request hook I where I can close the logger object
myself?
Hmm, seems like a bug in my code – should probably close the previous
logger before setting a new device. Try refreshing the paste: