README.md

daemon

Turn a node script into a daemon.

install via npm

npm install daemon

Requires node >= 0.8

examples

// this code is run twice// see implementation notes belowconsole.log(process.pid);
// after this point, we are a daemonrequire('daemon')();
// different pid because we are now forked// original parent has exitedconsole.log(process.pid);

api

daemon(opt)

Respawn the process (self) as a daemon. The parent process will exit at the point of this call.
opt parameter see below.

daemon.daemon(script, args, opt)

Spawn the script with given args array as a daemonized process. Return the child process object.

implementation notes

Daemon actually re-spawns the current application and runs it again. The only difference between the original and the fork is that the original will not execute past the daemon() call whereas the fork will.

node versions prior to 0.8

Using this module on older versions of node (or older versions of this module) are not recommended due to how node works internally and the issues it can cause for daemons.