How does one start a node.js server as a daemon process?

后端 未结 8 1456
余生分开走
余生分开走 2020-11-30 17:41

In Python Twisted, you have the twistd command that helps you with a number of things related to running your application (daemonize it for example).

Ho

相关标签:
8条回答
  • 2020-11-30 18:10

    UPDATE: i updated to include the latest from pm2:

    for many use cases, using a systemd service is the simplest and most appropriate way to manage a node process. for those that are running numerous node processes or independently-running node microservices in a single environment, pm2 is a more full featured tool.

    https://github.com/unitech/pm2

    http://pm2.io

    • it has a really useful monitoring feature -> pretty 'gui' for command line monitoring of multiple processes with pm2 monit or process list with pm2 list
    • organized Log management -> pm2 logs
    • other stuff:
      • Behavior configuration
      • Source map support
      • PaaS Compatible
      • Watch & Reload
      • Module System
      • Max memory reload
      • Cluster Mode
      • Hot reload
      • Development workflow
      • Startup Scripts
      • Auto completion
      • Deployment workflow
      • Keymetrics monitoring
      • API
    0 讨论(0)
  • 2020-11-30 18:20

    The simplest approach would just to send the command to the background.

    $ node server.js &
    

    Then you can kill the process at a later time. I usually do the following:

    $ killall node
    

    Note: I'm running OS X.

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