Iñaki Baz Castillo <[email protected]> wrote: > El Sábado, 26 de Diciembre de 2009, Iñaki Baz Castillo escribió: > > I'm playing right now with unicorn/launcher.rb (daemonize! method)but I > > get nothing. Unfortunatelly I think that the usage of fork makes very > > difficult the main command to behave as I desire (exit status). > > > > If you could give me some tips I'd try to implement it. > > I've implemented it! :) > > If you are interested please review this file (I cannot attach it in the mail > as it's rejected by the maillist): > > http://oversip.net/public/min_time_running.rb > > It contains a modification for bin/unicorn and a rewritten > lib/unicorn/launcher.rb.
Interesting, I could be tempted to accept this with a few changes... Process.detach() spawns a background Thread. Having running threads before forking won't fly with certain OS threading libraries (some versions of FreeBSD, I believe, check MRI Redmine for some open bugs). What you're trying to accomplish does not require threads. Use trap(Symbol), trap(Integer) is harder to read and has a likelyhood of being non-portable for certain signals. Likewise with Process.kill (0 being the only exception, of course). I would trap() in the parent before any forking, in case the sleep time is ever so low there's a race condition. Probably no need to handle USR1, either, just let the parent die on its own, or alternatively, have the parent sleep forever in case something unforseen happens in the children... > The code works for me for the two cases I explained in my previous mail. > Of course it's an optional feature (I've implemented it with "-M --min- > running-time SECONDS" in the options parser). I believe the nginx grace period is hard-coded at 5 seconds, which should be enough. -- Eric Wong _______________________________________________ Unicorn mailing list - [email protected] http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying
