diff --git a/lib/http/rpc.js b/lib/http/rpc.js index fea89f63..6de854fb 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -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.'; }); diff --git a/lib/workers/workerpool.js b/lib/workers/workerpool.js index 1ceac2ee..092f9c7a 100644 --- a/lib/workers/workerpool.js +++ b/lib/workers/workerpool.js @@ -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);