【问题标题】:Deploy node.js with zero downtime using naught使用 naught 以零停机时间部署 node.js
【发布时间】:2014-03-22 17:31:06
【问题描述】:
我开始使用 naught 来部署 node.js (https://github.com/andrewrk/naught)。
我在 Ubuntu Server 中有一个文件夹,其中包含我的 node.js(express) 应用程序。
我使用此文件夹中的“naught start app.js”部署它。
现在我想以零停机时间重新部署/更新我的代码。
我该怎么办?
假设我的代码在 git 服务器上,我是否在同一个文件夹中“git pull origin master”,然后“naught deploy”来部署新代码?或者我可能需要将新代码拉到新文件夹并以其他方式部署新代码?
【问题讨论】:
标签:
javascript
node.js
git
express
【解决方案1】:
从 Git 中提取最新更改并调用“naught deploy”应该可以解决问题。您不需要将代码克隆到不同的目录。
请注意,“deploy”命令需要一个 .ipc 文件,默认情况下会在您调用 deploy 的同一目录中查找它。如果在开始时您为 .ipc 文件指定了不同的位置,那么您应该使用该位置调用 deploy。
例如,如果你这样做了:
naught start app.js --ipc-file /var/run/naught.ipc
那么在部署的时候使用:
naught deploy /var/run/naught.ipc
在 BigPanda,我们以这种方式使用 naught in production,并且效果很好。