rebirth
v2.0.0
Published
Restart a node process from within itself
Downloads
17
Maintainers
Readme
rebirth
Restart a node process from within itself
Restarting is done by spawning a detached copy of the current process and subsequently ending the running process. The new child will be orphaned and parented to PID 1 (init/systemd/launchd).
Installation
$ npm install --save rebirth
Example
const rebirth = require('rebirth');
rebirth();
// process restarts
Notes:
- To detect if a process was reborn, check if
process.env.REBORN
is'1'
; - Standard streams will be inherited by default. When running in a terminal, this means stdout/stderr will still print to that terminal after a restart. If you don't care about these streams, set
opts.stdio = 'ignore'
.
API
rebirth([options])
options
{Object} Takes the same options aschild_process.spawn
.
© silverwind, distributed under BSD licence