Forever Node.JS Express 4

自古美人都是妖i 提交于 2020-01-10 07:18:56

问题


How do you run the Express 4 app with Forever? (or is there a new package?)

I am running my Express 3 apps with Forever installed locally with the package manager. I use the command:

forever -a start app.js

回答1:


Try this:

forever start ./bin/www

Let's take a look to package.json:

"scripts": {
    "start": "node ./bin/www"
},

I guess when we call npm start, ./bin/www will be executed at some point. Then look at the content of./bin/www:

var server = app.listen(app.get('port'), function() {
  debug('Express server listening on port ' + server.address().port);
});

so we are ready to listen for connections.




回答2:


forever start --minUptime 1000 --spinSleepTime 1000 ./bin/www



回答3:


Try node app.js first, for me, I added a new module in code base, but i did not run npm install in my AWS box, forever is not giving you the error, it just stopped silently, but node will give you the error




回答4:


If you use npm start to run your app, this works in place of it:

forever start -c "npm start" /path/to/app/dir/

Source: https://github.com/foreverjs/forever/issues/540




回答5:


http://expressjs.com/guide.html

in Expressjs guide doc,

use 'npm start'

I want use 'forever' but can not too

so,

add code at 'app.js'

var server = app.listen(3000, function() { console.log('Listening on port %d', server.address().port); });

and

$node app.js

can use it.

and forever can use too



来源:https://stackoverflow.com/questions/24072812/forever-node-js-express-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!