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

后端 未结 8 1523
余生分开走
余生分开走 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:01

    For the background on the normal way to daemonise on a POSIX system you can search for the C method.

    I have not seen enough methods in the node.js API to allow it to be done the C way by hand. However, when using child_process, you can have node.js do it for you:

    http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

    I consider this a potential waste of time because there's a good chance your system provides the same.

    For example:

    http://libslack.org/daemon/manpages/daemon.1.html

    If you want something portable (cross platform) the other posts offer solutions that might suffice.

提交回复
热议问题