为什么我的节点应用程序进程在我永远使用时总是停止? [英] Why does my node app process keep getting stopped when I use forever?

查看:25
本文介绍了为什么我的节点应用程序进程在我永远使用时总是停止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在免费层级 Amazon EC2 实例上,我设置了一个在 express 上运行的简单 node.js Hello World 应用程序.

On a free-tier Amazon EC2 instance, I set up a simple node.js Hello World app running on express.

如果我运行 npm start,我的应用程序运行良好,我可以从我的浏览器点击它,我看到以下输出:

If I run npm start, my app runs fine and I can hit it from my browser, and I see the following output:

> myappname@0.0.0 start /home/ec2-user/app
> node ./bin/www

我已经在全球范围内安装了永久工具.当我运行 forever start app.js 时,我看到:

I have installed the forever tool globally. When I run forever start app.js, I see:

warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: app/app.js

然而,当我检查forever list时,我看到进程已经停止:

However, when I check forever list, I see that the process has stopped:

info:    Forever processes running
data:        uid  command             script forever pid  id logfile                          uptime  
data:    [0] 2v0J /usr/local/bin/node app.js 2455    2457    /home/ec2-user/.forever/2v0J.log STOPPED 

这是日志中唯一的消息:error: Forever detection script was Killed by signal: null

This is the only message in the log: error: Forever detected script was killed by signal: null

我找不到任何其他日志信息.为什么它总是立即停止?

I'm unable to find any other log information. Why does it keep immediately stopping?

我尝试将它作为 nohup 永远启动 app.js 运行,但遇到了同样的问题.我在同一个 ssh 会话中一个接一个地运行 forever startforever list.应用程序的进程似乎立即停止.

I tried running it as nohup forever start app.js and got the same problem. I'm running the forever start and the forever list in the same ssh session, one after the other. The app's process seems to stop immediately.

推荐答案

多亏了对类似问题的回答,我才能够解决我的问题:https://stackoverflow.com/a/24914916/1791634

I was able to resolve my problem thanks to this answer on a similar question: https://stackoverflow.com/a/24914916/1791634

当我使用 forever start ./bin/www 而不是传递 app.js 时,进程一直在运行

The process kept running when I used forever start ./bin/www instead of passing app.js

这是否会在未来造成任何麻烦还有待观察.

It remains to be seen whether this causes any trouble down the road.

这篇关于为什么我的节点应用程序进程在我永远使用时总是停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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