Node Server crashes after few hours

前端 未结 2 523
[愿得一人]
[愿得一人] 2020-12-16 07:29

I am using Nodemon with Forever Module on Ubuntu Server.

I use this command to start my Node Server:

forever start -c nodemon app.js  --exitcrash
         


        
2条回答
  •  星月不相逢
    2020-12-16 07:51

    This is probably not the ideal answer but using forever-service with nodemon will ensure your server restarts after it crashes.

    This is the command that worked for me. I'm including it because getting forever-service and nodemon to play well can be tricky.

    It does the following: everytime a json or raml file in the applications dist/assets folder is modified, wait 10 seconds and then restart the node app (server.js script):

    $ forever-service install raml --script server.js -f " -c nodemon" -o " --delay 10 --watch dist/assets -e json,raml --exitcrash" -e "PATH=/usr/local/bin:$PATH"
    

    Then I can run:

    $ service raml start|stop|restart|status
    

    I can also have the service start on server reboot with the chkconfig utility:

    $ chkconfig --add raml
    $ chkconfig raml on
    

提交回复
热议问题