How do I run a node.js app as a background service?

前端 未结 26 1045
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 05:28

Since this post has gotten a lot of attention over the years, I\'ve listed the top solutions per platform at the bottom of this post.


Original post

26条回答
  •  感情败类
    2020-11-22 06:05

    I use Supervisor for development. It just works. When ever you make changes to a .js file Supervisor automatically restarts your app with those changes loaded.

    Here's a link to its Github page

    Install :

    sudo npm install supervisor -g

    You can easily make it watch other extensions with -e. Another command I use often is -i to ignore certain folders.

    You can use nohup and supervisor to make your node app run in the background even after you log out.

    sudo nohup supervisor myapp.js &

提交回复
热议问题