airbnb / hypernova

A service for server-side rendering your JavaScript views
MIT License
5.82k stars 207 forks source link

worker: Add graceful shutdown #147

Closed kpelelis closed 5 years ago

kpelelis commented 5 years ago

The graceful shutdown mechanism is only available for clustered installations (e.g. devMode = true). In our production stack, we are currently using multiple (HAProxy managed) single threaded instances of hypernova (e.g. devMode = true). This instances are actually systemd units so our init script is something along the lines of

# Start worker(s)
start_nova_workers() {
    for worker in $(nova_workers); do
      echo "Start ${worker}"
      systemctl start ${worker}
    done
  fi
}

Shutdown and restart is similar.

When we want to updated these instances, we do a rolling restart with HAProxy, which kills signals to each worker, in a round-robin manner, and re spawns it. There is a race condition in this shutdown process with open connections (as there is in the clustered version of hypernova). This patch introduces the same functionality with the single core installation.

kpelelis commented 5 years ago

Thanks a lot for merging this :) Is there a release schedule?