I have a app4.js
with content:
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
I'm on Win10 cmd
, I can success run it with node app4.js
and get Example app listening on port 3000!
,
but when I use forever -a forever.log start app4.js
, it show error
Forever detected script exited with code: 0
Where is the problem? How to solve it?
Cmd Message:
D:\app>node app4.js
Example app listening on port 3000!
^C
D:\app>forever -a forever.log start app4.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
error: Forever detected script exited with code: 0
Another Answer say it's related to ./bin/www
, but I can't understand what does it mean.
After some try I got it, here's my complete tring process:
1.In the beginning, I'm watching this video to learn forever
, and at 10:24
it use forever start server.js
and successfully run the server file.
2.Theoretically if I use forever start app4.js
it should success, but I got error:
D:\app>forever start app4.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: app4.js
error: Cannot start forever
error: log file C:\Users\admin\.forever\forever.log exists. Use the -a or --append option to append log.
3.By the message, I think I should use -a
to append log to some file, so I create a log file forever2.log
under current folder, and use forever -a forever2.log start app4.js
, the I got the error:
error: Forever detected script exited with code: 0
4.After some try, suddenly I look carefully to the nodejs book I'm reading, its example is forever start -l forever.log -o out.log -e err.log app.js
, that is the -x
is put between start
and app.js
, so I changed the command to forever start -a forever2.log app4.js
and got
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: forever2.log
That is it's processing forever2.log
, but what I want is app4.js
5.Finally I try forever start -a app4.js
, and I got
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: app4.js
Then I run Browser at http://localhost:3000/
, the Hello World! finally show!