Forever Node.JS Express 4

前端 未结 5 1613
时光取名叫无心
时光取名叫无心 2020-12-23 23:10

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

相关标签:
5条回答
  • 2020-12-23 23:15

    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.

    0 讨论(0)
  • 2020-12-23 23:23
    forever start --minUptime 1000 --spinSleepTime 1000 ./bin/www
    
    0 讨论(0)
  • 2020-12-23 23:28

    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

    0 讨论(0)
  • 2020-12-23 23:34

    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

    0 讨论(0)
  • 2020-12-23 23:40

    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

    0 讨论(0)
提交回复
热议问题