How to run Node.js as a background process and never die?

前端 未结 14 1087
刺人心
刺人心 2020-11-22 10:59

I connect to the linux server via putty SSH. I tried to run it as a background process like this:

$ node server.js &

However, after 2.5

14条回答
  •  [愿得一人]
    2020-11-22 11:40

    Nohup and screen offer great light solutions to running Node.js in the background. Node.js process manager (PM2) is a handy tool for deployment. Install it with npm globally on your system:

    npm install pm2 -g

    to run a Node.js app as a daemon:

    pm2 start app.js

    You can optionally link it to Keymetrics.io a monitoring SAAS made by Unitech.

提交回复
热议问题