Unicorn Signal Handling Shared for Other Servers

Eric Wong normalperson at yhbt.net
Mon Oct 4 01:41:24 EDT 2010

Ben Curren <ben at outright.com> wrote:
> I was curious if anyone has attempted to, or is interested, it ripping
> out Unicorn's signal handling and daemon code to make it possible to
> share with other Ruby Servers. I really love have 0 down time deploys
> and would love to have this in workling, thrift or other custom
> servers we have written. I'm more than willing to fork the code and
> take stab at it but wanted to check with the group to see if something
> has already been attempted. I'm not the type who likes to reinvent the
> wheel.

Hi Ben,

I recall some attempts to make libraries around what Unicorn did a year
ago when Unicorn started picking up more press.  I'm not sure how far
any of them got and can't remember the names, but October/November 2009
was the time frame.

Personally, I think the core Ruby methods around Unix APIs are
"just right" and extra wrappers either:

  a) take away needed flexibility
     (no, I don't want umask 0000 with my daemonize())

  b) require as much effort to learn as the Unix APIs
     (Process.daemon() in 1.9, really?)

The Unix APIs themselves are well-documented in manpages, textbooks,
and needless to say, useful outside of Ruby[1].

Ruby already does a great job of hiding the tedious, more painful parts
of the original C APIs from you.  Things like trap(signal, &block),
IO.select, and exceptions (vs writing error check for *everything*)
already make life much easier than before.

For Unicorn (and Rainbows!) development, one huge (maybe the biggest)
factor in trusting it is having integration tests that
start/stop/restart/thrash/nuke the server in various ways a user would.
The test suite hits signal handling logic, directory changes, process
creation/reaping, log file rotation, pid files, etc.  Some parts of the
test suite are ugly (test_exec.rb), but nevertheless effective at
finding bugs.

[1] - I'll admit to being reasonably experienced with Unix programming
      and worked on several daemons before I picked up Ruby.

Eric Wong

More information about the mongrel-unicorn mailing list