Raised exceptions are not logged when USR2

Iñaki Baz Castillo ibc at aliax.net
Sat Jan 2 11:42:29 EST 2010

Hi, I use the ready_pipe branch. I set "logger" to log into Syslog, but the 
issue I'll explain here is the same even if I log to a file.

I runned Unicorn daemonized. Now imagine I do a typo in my Rack config.ru (I 
use preload=true). When sending USR2 to the master it fails (ok) but the 
raised exception is not shown in the logger, instead it's lost as $stderr is 

Even worse, imagine Unicorn is not running and I start it daemonized (with a 
init script). Due to the typo in config.ru I see:

  "master failed to start, check stderr log for details"

But the message is useless since stderr is /dev/null so I se nothing in 

So I suggest the following:

If the process fails after setting the logger, then rescue any exception, log 
it to the logger and raise it as normal:

  rescue => err
    logger.fatal "#{err.class}: #{err.message}\n#{err.backtrace.join("\n")}"
    raise err

I'm trying to figure where exactly to include such code but it seems a bit 
complex. Any tip please?

Thanks a lot.

Iñaki Baz Castillo <ibc at aliax.net>

More information about the mongrel-unicorn mailing list