[DRE-maint] unicorn: native systemd service

Eric Wong e at 80x24.org
Thu Jun 25 23:26:26 UTC 2015


+Cc unicorn-public list 
Christos Trochalakis <christos at skroutz.gr> wrote:
> Hello all,
> 
> I have recently migrated our main ruby application to systemd implementing zero
> downtime upgrades.
> 
> systemd doesn't like replacing the binary on the fly. There is one exception to
> this, services with PIDFile. When PIDFile is set, systemd reads it when the
> main process exits and replaces the main process.  nginx also had this issue a
> few months ago [0].
> 
> So, in order to support zero-downtime upgrades we have to use a pid file.

I don't think so.  You should be able to bind the listen socket in
systemd and rely on the socket activation features (setting the
UNICORN_FD environment variable to the created FD).

You still need to have the matching "listen" directive in the unicorn
config file so unicorn does not close it.

With socket activation, you should just be able to kill unicorn using
SIGQUIT (just master, or even all workers) and restart without ever
dropping a connection.  I do NOT suggest using SIGTERM for unicorn,
since that'll cause the master to kill all workers ASAP.

If the master dies before the workers (e.g. from SIGKILL),
systemd ought to just ignore the workers.

I don't actually know the systemd config at all, but anybody familiar
with systemd socket activation should have no problems setting the
UNICORN_FD env.



More information about the Pkg-ruby-extras-maintainers mailing list