Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forever detected script exited with code: 0

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.

like image 293
yu yang Jian Avatar asked Feb 16 '26 07:02

yu yang Jian


1 Answers

It means try moving your app.js code to the www file in the bin directory.

in .bin/www

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!');
});

Also seems to be a known bug on certain versions of node/forever.

Issue

like image 92
user2263572 Avatar answered Feb 18 '26 21:02

user2263572