I am trying to run node server using forever command. I installed forever globally using:
我正在尝试使用forever命令运行节点服务器。我使用以下方式全球安装:
npm install forever -g
After installing forever I try to run my node script by using below command:
永远安装后,我尝试使用以下命令运行我的节点脚本:
node_modules\.bin\forever start app.js
Below is my console:
以下是我的控制台:
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up f
or at least 1000ms
info: Forever processing file: app.js
Please help me to resolve this issue!
请帮我解决这个问题!
7 个解决方案
#1
6
There is no problem here other than warnings for configs forever recommends you declare. If you see the final message there it tells you it has processed your script. Just run forever list
and you should see your script running.
除了永远建议您声明的配置警告之外,这里没有问题。如果您看到最后的消息,它会告诉您它已经处理了您的脚本。只需运行永远列表,您应该看到您的脚本正在运行。
I ran into this same thing when installing npm via yum repository ( yum install npm
) and then installing forever whereas when I install node and npm via shell scripts and then install forever it doesn't occur. It must have something to do with the formulas for the package installer or potentially missing alias with flags with installer to set those values behind the scene.
当我通过yum repository(yum install npm)安装npm然后永远安装时遇到了同样的事情,而当我通过shell脚本安装node和npm然后永远安装时它不会发生。它必须与程序包安装程序的公式有关,或者可能缺少带有安装程序标志的别名,以便在场景后面设置这些值。
Those don't mean it's not working. See below I created a js file using sample code from node's site and ran it manually (I flushed firewall to open port for app temporarily but you don't need that):
那些并不意味着它不起作用。请参阅下文我使用节点站点中的示例代码创建了一个js文件并手动运行(我刷新防火墙暂时打开应用程序的端口,但您不需要):
[root@app1 ~]# vi example.js
[root@app1 ~]# apf -f
apf(23924): {glob} flushing & zeroing chain policies
apf(23924): {glob} firewall offline
[root@app1 ~]# node example.js
Server running at http://127.0.0.1:1337/
I then start app using forever:
然后我永远开始使用app:
^C[root@app1 ~]# forever start example.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: example.js
Now I check to see if my app is running:
现在我检查我的应用程序是否正在运行:
[root@app1 ~]# forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] dan1 /usr/bin/node example.js 23976 23978 /root/.forever/dan1.log 0:0:0:27.320
[root@app1 ~]#
#2
1
This solved my issue:
这解决了我的问题:
forever start -c node [path/to/app]
"-c" means - Run commnad; and then just run via nodejs
“-c”表示 - 运行commnad;然后只通过nodejs运行
This way - you get the Respawn by default of min. 1000ms uptime
这样 - 默认情况下,你得到Respawn为min。 1000毫秒正常运行时间
Taken from: https://github.com/nodejitsu/forever/issues/422, by "Basarat"
取自:https://github.com/nodejitsu/forever/issues/422,来自“Basarat”
#3
1
First stop all running apps:
首先停止所有运行的应用:
forever stopall
then use this command. It works for me and solved my issue:
然后使用此命令。它适用于我并解决了我的问题:
forever -w ./bin/www
and you should find this in package.json file:
你应该在package.json文件中找到它:
"scripts": {
"start": "node ./bin/www"
}
I hope it helps you.
我希望它对你有所帮助。
#4
0
One thing that also produces same kind of output, but doesn't start the application is if forever
is unable to write to the specified log file. I had a case where the log file had become too big and this prevented the process from starting.
有一件事也产生相同类型的输出,但是如果永远无法写入指定的日志文件,则无法启动应用程序。我有一个案例,日志文件变得太大,这阻止了进程启动。
#5
0
Firstly change your package.json scripts like
首先更改你的package.json脚本
"scripts": {
"start": "forever ./bin/www.js"
}
than start this command on linux console:sudo npm start
在linux控制台上启动此命令:sudo npm start
for windows just :npm start
对于Windows只是:npm开始
#6
0
If you are using node js with express framework then script will not start using :
如果您使用带有快速框架的节点js,那么脚本将不会开始使用:
forever start app.js
First stop all running apps:
首先停止所有运行的应用:
forever stopall
When this Express framework used it must be started with:
当使用此Express框架时,必须以下面的方式启动它:
forever start ./bin/www
#7
-6
If you setup a module globaly (-g option) "forever" is in the $path
如果你设置了一个模块globaly(-g选项),“forever”就在$ path中
forever start app.js
should work.
应该管用。
#1
6
There is no problem here other than warnings for configs forever recommends you declare. If you see the final message there it tells you it has processed your script. Just run forever list
and you should see your script running.
除了永远建议您声明的配置警告之外,这里没有问题。如果您看到最后的消息,它会告诉您它已经处理了您的脚本。只需运行永远列表,您应该看到您的脚本正在运行。
I ran into this same thing when installing npm via yum repository ( yum install npm
) and then installing forever whereas when I install node and npm via shell scripts and then install forever it doesn't occur. It must have something to do with the formulas for the package installer or potentially missing alias with flags with installer to set those values behind the scene.
当我通过yum repository(yum install npm)安装npm然后永远安装时遇到了同样的事情,而当我通过shell脚本安装node和npm然后永远安装时它不会发生。它必须与程序包安装程序的公式有关,或者可能缺少带有安装程序标志的别名,以便在场景后面设置这些值。
Those don't mean it's not working. See below I created a js file using sample code from node's site and ran it manually (I flushed firewall to open port for app temporarily but you don't need that):
那些并不意味着它不起作用。请参阅下文我使用节点站点中的示例代码创建了一个js文件并手动运行(我刷新防火墙暂时打开应用程序的端口,但您不需要):
[root@app1 ~]# vi example.js
[root@app1 ~]# apf -f
apf(23924): {glob} flushing & zeroing chain policies
apf(23924): {glob} firewall offline
[root@app1 ~]# node example.js
Server running at http://127.0.0.1:1337/
I then start app using forever:
然后我永远开始使用app:
^C[root@app1 ~]# forever start example.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: example.js
Now I check to see if my app is running:
现在我检查我的应用程序是否正在运行:
[root@app1 ~]# forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] dan1 /usr/bin/node example.js 23976 23978 /root/.forever/dan1.log 0:0:0:27.320
[root@app1 ~]#
#2
1
This solved my issue:
这解决了我的问题:
forever start -c node [path/to/app]
"-c" means - Run commnad; and then just run via nodejs
“-c”表示 - 运行commnad;然后只通过nodejs运行
This way - you get the Respawn by default of min. 1000ms uptime
这样 - 默认情况下,你得到Respawn为min。 1000毫秒正常运行时间
Taken from: https://github.com/nodejitsu/forever/issues/422, by "Basarat"
取自:https://github.com/nodejitsu/forever/issues/422,来自“Basarat”
#3
1
First stop all running apps:
首先停止所有运行的应用:
forever stopall
then use this command. It works for me and solved my issue:
然后使用此命令。它适用于我并解决了我的问题:
forever -w ./bin/www
and you should find this in package.json file:
你应该在package.json文件中找到它:
"scripts": {
"start": "node ./bin/www"
}
I hope it helps you.
我希望它对你有所帮助。
#4
0
One thing that also produces same kind of output, but doesn't start the application is if forever
is unable to write to the specified log file. I had a case where the log file had become too big and this prevented the process from starting.
有一件事也产生相同类型的输出,但是如果永远无法写入指定的日志文件,则无法启动应用程序。我有一个案例,日志文件变得太大,这阻止了进程启动。
#5
0
Firstly change your package.json scripts like
首先更改你的package.json脚本
"scripts": {
"start": "forever ./bin/www.js"
}
than start this command on linux console:sudo npm start
在linux控制台上启动此命令:sudo npm start
for windows just :npm start
对于Windows只是:npm开始
#6
0
If you are using node js with express framework then script will not start using :
如果您使用带有快速框架的节点js,那么脚本将不会开始使用:
forever start app.js
First stop all running apps:
首先停止所有运行的应用:
forever stopall
When this Express framework used it must be started with:
当使用此Express框架时,必须以下面的方式启动它:
forever start ./bin/www
#7
-6
If you setup a module globaly (-g option) "forever" is in the $path
如果你设置了一个模块globaly(-g选项),“forever”就在$ path中
forever start app.js
should work.
应该管用。