Issue when sending USR2 too soon

Eric Wong normalperson at
Mon Jan 18 06:04:47 EST 2010

Iñaki Baz Castillo <ibc at> wrote:
> El Domingo, 17 de Enero de 2010, Iñaki Baz Castillo escribió:
> > What about if Unicorn very quicky prepares the trap for USR2 so in case it 
> > receives it soon when starting it ignores it (and logs some warning)?
> > Does it make sense?
> Adding the following on the top of bin/unicorn solves the problem:
>   # Ignore USR2 (instead of terminating script) in case it arrives too soon.
>   trap("USR2") do
>     $stderr.puts "WARN: USR2 signal (reload action) received too soon, ignored"
>   end

No it doesn't, it just reduces the window where signals aren't setup.
On systems where Unicorn is installed as a RubyGem, that window of time
may be much bigger.

Is the issue with a script reading the pid file and sending the signal
because it exists?

In that case, it might be better to drop the pid file after
setting up signal handlers, but I seem to recall some tools wanting
the pid file earlier...  I'll get back to this on Tuesday.

Eric Wong

More information about the mongrel-unicorn mailing list