为什么当我永远使用我的节点应用程序进程不断停止?
在免费层的Amazon EC2实例上,我设置了一个运行在express上的简单的node.js Hello World应用程序。
如果我运行npm start
,我的应用程序运行良好,我可以从我的浏览器中打开,我看到以下输出:
> myappname@0.0.0 start /home/ec2-user/app > node ./bin/www
我已经在全球安装了永久工具。 当我forever start app.js
运行forever start app.js
,我看到:
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
,我看到过程已经停止:
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 detected script was killed by signal: null
我无法find任何其他日志信息。 为什么它会立即停止?
编辑:我试图运行它作为nohup forever start app.js
并得到同样的问题。 我正在一个接一个地在同一个ssh会话中运行forever start
和forever list
。 应用程序的过程似乎立即停止。
我猜这个过程在你从ssh断开连接后会停止。
尝试先用nohup
永远运行。
nohup forever start app.js
当你从ssh断开连接时,服务器会杀死你所有的shellsubprocess。 nohup
断开一个进程从它的父shell。
我能解决我的问题感谢这个答案在类似的问题: https : //stackoverflow.com/a/24914916/1791634
当我forever start ./bin/www
使用forever start ./bin/www
而不是传递app.js时,进程保持运行
这是否会造成任何麻烦还有待观察。
对我来说,我不得不用“永远的sudo”来工作。