简体   繁体   English

我可以在新贵公司中运行PM2集群吗?

[英]Can I run a PM2 cluster with upstart?

I have written a NodeJS service, that will run continuously. 我已经编写了一个NodeJS服务,它将连续运行。 I want to run two copies of it using PM2. 我想使用PM2运行它的两个副本。

I am also trying to write an upstart script for it, and I couldn't make it work (basically stop wouldn't work, the PID was never correct. 我也在尝试为此编写一个新贵的脚本,但我无法使其正常运行(基本上stop不起作用,PID永远不正确。

I read a bit on upstart's expect stanza, which tells upstart whether the service forks zero times, once or twice, and I realized that PM2 forks 4 times and then ends, so there is no PID for upstart to kill to stop the process. 我读了一些关于upstart的expect节的信息,该节告诉upstart服务是否分叉零次,一次或两次,并且我意识到PM2分叉4次然后结束,因此没有PID可供upstart杀死以停止进程。

Should I just abandon upstart and write a different kind of startup script for my service? 我是否应该放弃暴发户并为我的服务编写其他类型的启动脚本?

After snooping around, I think I can answer my own question: no, upstart isn't suitable for this kind of task, it needs one PID that it can kill to bring the service down. 窥探一下之后,我想我可以回答我自己的问题:不,暴发户不适合此类任务,它需要一个PID才能杀死它以降低服务质量。 In the case of PM2, there is no such PID, and also, the way to "stop" the service isn't to kill one process, but to run one ( pm2 stop all or pm2 kill ). 对于PM2,没有这种PID,并且“停止”服务的方法不是杀死一个进程,而是运行一个进程( pm2 stop allpm2 kill )。 So, I fell back to pm2's own generated bash startup script. 因此,我回到了pm2自己生成的bash启动脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM