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

  1. fire updated instance of backup server , confirm , responding api requests.
  2. send shutdown command main server calls server.close() , start setting header res.setheader('connection', 'close') requests may still come through due keep-alive connections.
  3. wait till close event fired , confirm server.getconnections returns 0 active connections.
  4. update main server git pull , bring up
  5. confirm , responding api requests.
  6. take down backup server

problem

i'm receiving 502 errors nginx while main server down.


Comments

Popular posts from this blog

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -