Closed ybogdanov closed 13 years ago
Temporarily, I spawn new process in new session:
var start = process.argv[process.argv.length - 1] === 'start';
if (start) {
var node = process.execPath,
cmd = process.argv.slice(1, -1);
spawn(node, cmd, { env : process.env, setsid: true });
process.exit(0);
}
// require, initialize, start cluster here...
And then $ myapp.js start
yeah to achieve similar right now we would have to pretty much do exactly what you're doing
Ok, thanks!
Just a suggestion: maybe adding a command to cli? Something like this?
define('-b, --background, background', function(master) {
master.on('listening', function () {
master.killall('SIGUSR2');
});
}, 'Start master in background');
The only problem is the part:
90 if (~command.flags.indexOf(arg)) {
91 command.callback(master);
92 process.exit(0);
93 }
Because the process exists. Maybe adding a switch to command exit_after
or checking the return value do_exit = command.callback(master)
@alefnula yeah i know i have that there for a reason but ill see if i can use the preventDefault() stuff i added a while back
I'm sure there is a much better way of doing it :) It was just the first thing I found that could work after a quick look at the code. But thanks for taking the cli background suggestion into account :)
Hi,
nohup is good, but it kills the process at the end of session. I use capistrano to run commands on remote servers, e.g. start/stop/restart clusterized processes.
The quesion: what is the best way to start cluster process remotely and bring it to background?
Thanks!