rpc: ensure shutdown. see #188.
This commit is contained in:
parent
a5520abaae
commit
4f09065a3e
@ -195,10 +195,22 @@ RPC.prototype.help = co(function* _help(args, help) {
|
||||
});
|
||||
|
||||
RPC.prototype.stop = co(function* stop(args, help) {
|
||||
var self = this;
|
||||
|
||||
if (help || args.length !== 0)
|
||||
throw new RPCError(errs.MISC_ERROR, 'stop');
|
||||
|
||||
this.node.close();
|
||||
co(function* () {
|
||||
try {
|
||||
yield self.node.close();
|
||||
} catch (e) {
|
||||
if (process.exit)
|
||||
process.exit(1);
|
||||
return;
|
||||
}
|
||||
if (process.exit)
|
||||
process.exit(0);
|
||||
})();
|
||||
|
||||
return 'Stopping.';
|
||||
});
|
||||
|
||||
@ -537,6 +537,7 @@ Worker.prototype._initChildProcess = function _initChildProcess() {
|
||||
var options = { stdio: 'pipe', env: env };
|
||||
|
||||
this.child = cp.spawn(file, argv, options);
|
||||
this.child.unref();
|
||||
|
||||
this.child.on('error', function(err) {
|
||||
self.emit('error', err);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user