unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* How to trap USR2 for custom ussage ?
@ 2009-12-23 14:29 Iñaki Baz Castillo
  2009-12-23 20:47 ` Eric Wong
  0 siblings, 1 reply; 6+ messages in thread
From: Iñaki Baz Castillo @ 2009-12-23 14:29 UTC (permalink / raw)
  To: mongrel-unicorn

Hi, I've modified bin/unicorn to start a DRb server before last lines:

  MyApp::DRbServer.start(Process.pid)
  Unicorn::Launcher.daemonize! if daemonize
  Unicorn.run(app, 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)

The only solution I can imagine is to trap USR2 signal:

  MyApp::DRbServer.start(Process.pid)
  trap("USR2") { ::DRb.stop_service }
  Unicorn::Launcher.daemonize! if daemonize
  Unicorn.run(app, options)

Unfortunatelly it doesn't work because Unicorn overrides the 'trap' call so I 
don't get the USR2 signal.


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?

Thanks a lot.

-- 
Iñaki Baz Castillo <ibc@aliax.net>
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-26  5:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-23 14:29 How to trap USR2 for custom ussage ? Iñaki Baz Castillo
2009-12-23 20:47 ` Eric Wong
2009-12-24  9:40   ` Iñaki Baz Castillo
2009-12-24 19:41     ` Eric Wong
2009-12-25 22:16       ` Iñaki Baz Castillo
2009-12-26  5:53         ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).