How to trap USR2 for custom ussage ?

Eric Wong normalperson at
Wed Dec 23 15:47:05 EST 2009

Iñaki Baz Castillo <ibc at> wrote:
> Hi, I've modified bin/unicorn to start a DRb server before last lines:
>   MyApp::DRbServer.start(
>   Unicorn::Launcher.daemonize! if daemonize
>, options)
> DRb server listens in port 5555. When I send a USR2 signal to unicorn master 
> process I get an error because DRb is started again so:
>   /usr/local/lib/ruby1.9/1.9.1/drb/drb.rb:861:in `initialize': Address already
>   in use - bind(2) (Errno::EADDRINUSE)

First off I really don't think you need to be using DRb for this or
(generally) sticking things into the master process that don't belong

> Is there any way to achive this?
> I could imagine a new config option "on_usr2" (or "before_reexec") so the 
> passsed block would be executed upon receipt of USR2 (before the real "reexec" 
> method).
> Does it make sense?

There's already a similar before_exec hook documented in
But it is called after forking, so the listener will be shared.

But again, you don't need to use DRb for this.

Eric Wong

More information about the mongrel-unicorn mailing list