Is it possible to create child processes in node.js which do not exit when their parents do?

Is it possible to create child processes in node.js which do not exit when their parents do?

I'm running node v0.6.19.

Yes, it's possible.

npm install daemon

test1.js:

var
    spawn = require('child_process').spawn,
    test2 = spawn('node', ['test2.js']);

    console.log(test2.pid);

test2.js:

var daemon = require('daemon');
daemon.start();

setInterval(function() {
    // do something
}, 1000);

test1.js will spawn test2.js and exit. test2.js will continue to work in the background.

Yes, use child_process.spawn and pass the detached option, then call child.unref().

Make sure you read the notes: http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

Search for a npm package that fit you needs. There are plenty of them available (at least if you are on a *nix system).