indexzero/daemon.node — pull request #27 by shtylman (2013-02-19 20:38:03+00:00)
Title: rework module for node >= 0.8

**This is a complete API and functionality break.**

The new code uses the `detach` feature of `child_process.spawn` to respawn the main process again (using the same args and all). The parent (original) exists at the point of daemonization and the child (new one) continues past the point of daemonization.

Note that because the original process is respawned, the code before the `daemon()` call is run twice. This is an important side effect to insure a clean respawn.

The user can optionally pass in a `stdout` and `stderr` value which is passed to `.spawn()`. This makes it possible to capture the output into a log file of the spawned child from the parent.

See the readme in this pull request (or my repo) for an example.