node.js, forever & nginx with 0% downtime upgrades -
the goal here update server via git pull , restart server while using upgraded backup instance avoid missing requests. below nginx config.
nginx backend config
upstream backend { server localhost:8008 max_fails=1 fail_timeout=3s; server localhost:9008 backup; } workflow
- fire updated instance of backup server , confirm , responding api requests.
- send
shutdowncommand main server callsserver.close(), start setting headerres.setheader('connection', 'close')requests may still come through duekeep-aliveconnections. - wait till
closeevent fired , confirmserver.getconnectionsreturns 0 active connections. - update main server
git pull, bring up - confirm , responding api requests.
- take down backup server
problem
i'm receiving 502 errors nginx while main server down.
Comments
Post a Comment