Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

daemonize-process

2.0.1 • Public • Published

daemonize-process

Daemonize the current Node.js process

The module re-spawns the current process and then exits, which will lead to the new child process being adopted by init or similar mechanisms, effectively putting the current process into the background.

Differences to the popular daemon module include:

  • Exposes all options of child_process.spawn.
  • Cleans up process.env after itself.
  • Works on Node.js >= 8.

Install

$ npm install daemonize-process

Examples

require('daemonize-process')();
import daemonizeProcess from 'daemonize-process';
daemonizeProcess();

API

daemonizeProcess([options])

The options object can contain any valid child_process.spawn option as well as these properties:

  • script string - The path to the script to be executed. Default: The current script.
  • arguments Array - The command line arguments to be used. Default: The current arguments.
  • node string - The path to the Node.js binary to be used. Default: The current Node.js binary.
  • exitCode number - The exit code to be used when exiting the parent process. Default: 0.

By default the standard streams of the child are ignored (e.g. attached to /dev/null or equivalent). If you need these streams, adjust the stdio option.

License

© silverwind, distributed under BSD licence

install

npm i daemonize-process

Downloadsweekly downloads

289

version

2.0.1

license

BSD-2-Clause

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability