Re: supervising nginx

From: Patrick Mahoney <pat_at_polycrystal.org>
Date: Thu, 24 Jul 2014 13:28:19 -0500

On 23.07.2014 18:47, Alex Efros wrote:

> Is it possible to run nginx under runsv supervision without breaking
> nginx's ability to upgrade (SIGUSR2) or reload config (SIGHUP)
> gracefully
> without interrupting current connections?

I'm interested in ideas around this as well. SIGHUP shouldn't be an
issue for anything. I'm running nginx under s6, and "s6-svc -h
/service/nginx" after a config upgrade works perfectly.

Unicorn is a Ruby appserver that does nginx-style upgrades. What I've
done in the past is a giant hack:

Instead of supervising unicorn (or nginx) directly, supervise a
long-running shell script that invokes unicorn (as a traditional
daemon) which it monitors via pidfile, so little benefit over sysv
init scripts. The shell script installs signal handlers to forward
various signals on to the master process. The shell script
orchestrates the upgrade by forwarding SIGUSR2 and watching for
pidfile changes so that can keep track of the new master. If the
master dies, the shell script exits so the supervisor can restart, but
since the (daemonized) master process is not a child, it must poll
using the pid.

I find myself caring less and less about nginx's ability to upgrade
without dropping connections since most of what I work on today has
multiple instances behind a load balancer, where some kind of rolling
upgrade can be performed.

-- 
Patrick Mahoney
Received on Thu Jul 24 2014 - 18:28:19 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:18 UTC