CentOs 6.5 using root acount, I have a working Node.js Express app:
root@vps [/home/test/node]# npm start app.js
> [email protected] start /home/test/node
> node ./bin/www app.js
The app can be seen working on the internet browser. I stop the app and try to run it with forever:
root@vps [/home/test/node]# 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.js
root@vps [/home/test/node]#
Throws a couple of warnings that should not be a problem and looks like it should be working but its not showing on the browser, forever list:
root@vps [/home/test/node]# forever list
info: Forever processes running
data: uid mand script forever pid id logfile uptime
data: [0] OkGm /usr/local/bin/node app.js 32222 32227 /root/.forever/OkGm.log STOPPED
root@vps [/home/test/node]#
If I check OkGm.log:
error: Forever detected script exited with code: 0
Why is the app not working when I run it with forever?
CentOs 6.5 using root acount, I have a working Node.js Express app:
root@vps [/home/test/node]# npm start app.js
> [email protected] start /home/test/node
> node ./bin/www app.js
The app can be seen working on the internet browser. I stop the app and try to run it with forever:
root@vps [/home/test/node]# 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.js
root@vps [/home/test/node]#
Throws a couple of warnings that should not be a problem and looks like it should be working but its not showing on the browser, forever list:
root@vps [/home/test/node]# forever list
info: Forever processes running
data: uid mand script forever pid id logfile uptime
data: [0] OkGm /usr/local/bin/node app.js 32222 32227 /root/.forever/OkGm.log STOPPED
root@vps [/home/test/node]#
If I check OkGm.log:
error: Forever detected script exited with code: 0
Why is the app not working when I run it with forever?
Share Improve this question edited Mar 26, 2015 at 12:13 user2879427 asked Mar 26, 2015 at 11:13 user2879427user2879427 2111 gold badge2 silver badges6 bronze badges 3-
The reason for the exit of your application should be right before the line
error: Forever detected script exited with code: 0
in your logs. Most likely anEACCES
error or something similar. – t.niese Commented Mar 26, 2015 at 11:25 - @t.niese There is nothing more in the log file, only that line. When I try to run it again forever creates another log file with a different name with the same line again. – user2879427 Commented Mar 26, 2015 at 11:29
-
Then you either suppress an error message with a
try
-catch
block or anon('error', ...)
without handling it in a way that it informs you that the express server (?) will be started. Or you do a check if you can start it which does not succeed and you don't start it as of that. Not matter what the reason is, its only you that can find out why. I would suggest to add some logging into your app. So that you can detect which steps are executed and which are not. – t.niese Commented Mar 26, 2015 at 11:36
1 Answer
Reset to default 17Ok I found out what was happening. I was trying to run:
forever start app.js
When this Express app must be started with:
forever start ./bin/www
There was no useful info on internet when searching for this by the error log output ("exited with code: 0"), so I hope this answer helps begginers like me in what I think can be an easy mistake to make.