Hi!
On Thu, Jul 24, 2014 at 02:47:29AM +0300, Alex Efros wrote:
> Is it possible to run nginx under runsv supervision without breaking
> nginx's ability to upgrade (SIGUSR2) gracefully without interrupting
> current connections?
Looks like this workaround may solve this issue, but I'm not sure about
possible races.
1. Create copy of nginx service as nginx2.
2. touch nginx2/down
3. Add this ./finish to both services:
#!/bin/sh
test -f down && sv d .
4. Add this control/q to nginx service:
#!/bin/sh
mv ../nginx2/down ./
sv u ../nginx2
sleep 1
exit 1
5. Add this control/q to nginx2 service:
#!/bin/sh
mv ../nginx/down ./
sv u ../nginx
sleep 1
exit 1
6. Activate nginx2 service (make symlink in /etc/service/ or /var/service/
etc. - in directory handled by runsvdir).
Now you can `sv q nginx` or `sv q nginx2` (depending on which one of
currently running) to gracefully upgrade/restart it.
I'm afraid there is still some small window when neither new nor old nginx
will listen on ports - new nginx log this on start:
[emerg] 18098#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg] 18098#0: bind() to 192.168.2.1:443 failed (98: Address already in use)
[notice] 18098#0: try again to bind() after 500ms
According to
http://nginx.org/en/docs/control.html#upgrade nginx is able
to start new master process using new binary (so it can't use fork and
thus can't inherit listen socket) and have both old and new master
processes accept connections. I suppose it use SO_REUSEADDR in this case,
but I don't know how to activate it manually from ./run or nginx config.
--
WBR, Alex.
Received on Sat May 02 2015 - 11:14:27 UTC