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

前端 未结 26 1417
隐瞒了意图╮
隐瞒了意图╮ 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:10

    The accepted answer is probably the best production answer, but for a quick hack doing dev work, I found this:

    nodejs scriptname.js & didn't work, because nodejs seemed to gobble up the &, and so the thing didn't let me keep using the terminal without scriptname.js dying.

    But I put nodejs scriptname.js in a .sh file, and nohup sh startscriptname.sh & worked.

    Definitely not a production thing, but it solves the "I need to keep using my terminal and don't want to start 5 different terminals" problem.

提交回复
热议问题