如何停止节点。在Windows上使用forever模块的js应用程序?

时间:2022-08-19 18:29:18

I have gone through so many questions regarding forever module for nodejs APP, but did not find my answer.

我已经问了很多关于node . js应用的永久模块的问题,但是没有找到我的答案。

Forever module is working fine on a Linux box but now I am putting my APP on Windows 7 and trying to run it with forever. First i installed forever module as

永远的模块在Linux系统上运行良好,但现在我将我的应用程序放在Windows 7上,并试图永远运行它。首先我安装了forever模块as

npm install forever -g

after that i ran my app as

在那之后,我运行了我的应用程序。

forever start app.js

it's running fine by saying file app.js is running with forever and I am accessing my app successfully.

说file app.js将永远运行,我正在成功访问我的应用程序,这样运行很好。

When I execute a command forever stop app.js I get the error

当我执行命令forever stop app.js时,我得到了错误

no forever file is running

没有永久文件正在运行

Please suggest me if anyone has used forever on windows that how can i stop my application on Windows.

如果有人在windows上使用了forever,请建议我如何在windows上停止我的应用程序。

4 个解决方案

#1


69  

use forever list then forever stop with the id, e.g. forever stop 0

使用永久列表,然后永远停止使用id,例如永远停止0。

Here is a sample output

这是一个输出示例

user@some-server]$ forever list
info:    Forever processes running
data:        uid  command                                                  script forever pid   id logfile                          uptime        
data:    [0] 9Xzw ng serve --host 0.0.0.0 --port 4009         13164   29579    /home/ec2-user/.forever/9Xzw.log 7:1:20:50.412 
data:    [1] wOj1 npm run-script app-start-dev                                    29500   24978    /home/ec2-user/.forever/wOj1.log 0:0:5:3.433

Here 0 is like an index which is in the first column of the output. If there are two processes running, we can use indexes like 0 or 1 to stop the first or the second process.

这里0就像在输出的第一列中的一个索引。如果有两个进程在运行,我们可以使用诸如0或1之类的索引来停止第一个或第二个进程。

forever stop 0 OR forever stop 1

永远停止0或永远停止1。

#2


9  

I had this same issue and found that it was because I was running forever start with sudo (on Linux) so that I could run a production site on port 80. This did the trick:

我也遇到了同样的问题,因为我一直在运行sudo(在Linux上),所以我可以在端口80上运行一个生产站点。这个诀窍:

sudo forever list

#3


6  

It's a bug in windows https://github.com/nodejitsu/forever/issues/337 If you need to stop your app just open task manager and find node.js process and kill it. Hard but work.

这是windows https://github.com/nodejitsu/forever/issues/337上的一个错误,如果你需要停止你的应用,只要打开任务管理器并找到node。js处理并杀死它。但是努力。

#4


3  

This is just to expand on @laktak's answer. The result of forever list on Windows will look something like this:

这只是为了扩展@laktak的答案。永远列表在Windows上的结果是这样的:

info: Forever processes running data: uid command script forever p id id logfile uptime data: [0] an1b "C:\nodejs\node.exe" C:\sbSerialWidget\server.js 8780 1 0152 C:\Users\username\.forever\an1b.log STOPPED

信息:永远处理正在运行的数据:uid命令脚本永远p id日志文件运行时间数据:[0]an1b "C:\nodejs\节点。exe”C:\ sbSerialWidget \服务器。js 8780 1 0152 C:\Users\username\.forever\an1b.日志了

I wasn't sure which one was the ID initially, but I figured out that it was the first entry after the second data field above, so the line you're interested in is with the ID bolded & italicized:

我最初不确定哪个是ID,但我发现它是上面第二个数据字段之后的第一个条目,所以您感兴趣的行是ID黑体字和斜体字:

data: [0] an1b "C:\nodejs\node.exe" C:\sbSerialWidget\server.js 8780 1 0152 C:\Users\username.forever\an1b.log STOPPED

数据:C:\ nodejs \[0]an1b”节点。exe”C:\ sbSerialWidget \服务器。js 8780 1 0152 C:\Users\ username.forever \ an1b。日志了

So to stop this particular instance, you'd run:

因此,要停止这个特定的例子,你应该:

forever stop 0

永远停止0

Hope this helps someone else who was confused like I was

希望这能帮助像我一样困惑的人。

#1


69  

use forever list then forever stop with the id, e.g. forever stop 0

使用永久列表,然后永远停止使用id,例如永远停止0。

Here is a sample output

这是一个输出示例

user@some-server]$ forever list
info:    Forever processes running
data:        uid  command                                                  script forever pid   id logfile                          uptime        
data:    [0] 9Xzw ng serve --host 0.0.0.0 --port 4009         13164   29579    /home/ec2-user/.forever/9Xzw.log 7:1:20:50.412 
data:    [1] wOj1 npm run-script app-start-dev                                    29500   24978    /home/ec2-user/.forever/wOj1.log 0:0:5:3.433

Here 0 is like an index which is in the first column of the output. If there are two processes running, we can use indexes like 0 or 1 to stop the first or the second process.

这里0就像在输出的第一列中的一个索引。如果有两个进程在运行,我们可以使用诸如0或1之类的索引来停止第一个或第二个进程。

forever stop 0 OR forever stop 1

永远停止0或永远停止1。

#2


9  

I had this same issue and found that it was because I was running forever start with sudo (on Linux) so that I could run a production site on port 80. This did the trick:

我也遇到了同样的问题,因为我一直在运行sudo(在Linux上),所以我可以在端口80上运行一个生产站点。这个诀窍:

sudo forever list

#3


6  

It's a bug in windows https://github.com/nodejitsu/forever/issues/337 If you need to stop your app just open task manager and find node.js process and kill it. Hard but work.

这是windows https://github.com/nodejitsu/forever/issues/337上的一个错误,如果你需要停止你的应用,只要打开任务管理器并找到node。js处理并杀死它。但是努力。

#4


3  

This is just to expand on @laktak's answer. The result of forever list on Windows will look something like this:

这只是为了扩展@laktak的答案。永远列表在Windows上的结果是这样的:

info: Forever processes running data: uid command script forever p id id logfile uptime data: [0] an1b "C:\nodejs\node.exe" C:\sbSerialWidget\server.js 8780 1 0152 C:\Users\username\.forever\an1b.log STOPPED

信息:永远处理正在运行的数据:uid命令脚本永远p id日志文件运行时间数据:[0]an1b "C:\nodejs\节点。exe”C:\ sbSerialWidget \服务器。js 8780 1 0152 C:\Users\username\.forever\an1b.日志了

I wasn't sure which one was the ID initially, but I figured out that it was the first entry after the second data field above, so the line you're interested in is with the ID bolded & italicized:

我最初不确定哪个是ID,但我发现它是上面第二个数据字段之后的第一个条目,所以您感兴趣的行是ID黑体字和斜体字:

data: [0] an1b "C:\nodejs\node.exe" C:\sbSerialWidget\server.js 8780 1 0152 C:\Users\username.forever\an1b.log STOPPED

数据:C:\ nodejs \[0]an1b”节点。exe”C:\ sbSerialWidget \服务器。js 8780 1 0152 C:\Users\ username.forever \ an1b。日志了

So to stop this particular instance, you'd run:

因此,要停止这个特定的例子,你应该:

forever stop 0

永远停止0

Hope this helps someone else who was confused like I was

希望这能帮助像我一样困惑的人。