Zero downtime deployment Nodejs application

对着背影说爱祢 提交于 2019-12-08 05:26:38

问题


I have a Nodejs application that included clustering for being uptime and domain for error handling.

Now for achieving zero downtime deployment, I have an instruction but I need help to convert this instruction to Nodejs code (I need an example for it please).

This is the instruction:

  1. When master starts, give it a symlink to worker code.
  2. After deploying new code, update symlink
  3. Send a signal to master: fork new workers!
  4. Mater tells old workers to shut down, forks new workers from new code.
  5. Mater process never stop running

Instruction source -> slide number 39


回答1:


For 100% uptime the road is more or less the same regardless of the language you are using:

  • Store your session tokens in a database rather than in an in-memory array or something. This will allow users to stay logged-in after you swap versions.

  • Run your server inside a Docker container

  • Use a proxy to handle swapping containers when you need to run a new server version.

I wrote easy-deploy to handle exactly that, so that I wouldn't need to worry about setting up the proxy every time.

Deploy version 1

easy-deploy -p 80:80 -v some/path:other/path my-image:1

To deploy a new version just run the command with the updated tag name

easy-deploy -p 80:80 -v some/path:other/path my-image:2

The proxy is taken care of. my-image:1 will be replaced by my-image:2 without letting any request drop.



来源:https://stackoverflow.com/questions/44353368/zero-downtime-deployment-nodejs-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!