尝试仅关闭一个时,永远关闭同名的 node.js 进程 [英] node.js processes with the same name in forever are closed when trying to close only one

查看:73
本文介绍了尝试仅关闭一个时,永远关闭同名的 node.js 进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 aws 上部署两个 node.js 应用程序,这两个应用程序位于所示路径中

I am deploying two node.js apps on the aws, the two apps are in the paths shown as

/home/ubuntu/nodes/app1/app.js
/home/ubuntu/nodes/app2/app.js

分别

为了在后台运行 node.js 应用程序,我使用永远启动两个应用程序,所以像

to run the node.js apps in the background, I used forever to start two apps, so like

   $ sudo forever start /home/ubuntu/nodes/app1/app.js
   $ sudo forever start /home/ubuntu/nodes/app2/app.js

因此,通过在后台进程中运行两个 node.js 应用程序,永远运行良好.但是,当我尝试使用这样的永久命令停止一个进程时.

so forever works well by running the two node.js apps in the background process. However, when I tried to stop one process with forever command like this.

   $ sudo forever stop /home/ubuntu/nodes/app1/app.js

出乎意料的是,两个 node.js 进程都被这样的信息关闭了

unexpectedly, both node.js process are closed with info like this

info:    Forever stopped process:
data:        uid  command         script forever pid   logfile                 uptime
[0] r2pZ /usr/bin/nodejs app.js 24852   24854 /root/.forever/r2pZ.log 0:0:1:14.775
[1] 9f2h /usr/bin/nodejs app.js 24870   24872 /root/.forever/9f2h.log 0:0:0:58.733

我认为这是因为两个 node.js 进程具有相同的名称 - app.js,如何通过仅关闭一个进程来避免这种情况

I assume it is because two node.js process has the same name - app.js, how to avoid this by close only one process

推荐答案

您只能使用 forever list 命令中显示的进程索引杀死一个进程.例如,如果你输入forever stop 1,只有索引为1的进程会被杀死

You can kill only one process using the index of the process shown in the forever list command. For example, if you type forever stop 1, only the process with the index 1 will be killed

这篇关于尝试仅关闭一个时,永远关闭同名的 node.js 进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆