Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid recursive exit calls

  • Loading branch information...
commit 9bf988eb530db5256ca159b45e1515428ef8a38f 1 parent 30657dd
Kris Zyp authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 lib/multi-node.js
15 lib/multi-node.js
View
@@ -98,7 +98,9 @@ exports.listen = function(options, server){
}
});
- process.exit();
+ if(signal !== 'exit'){
Vladimir Dronnikov
dvv added a note

How do I order to kill children without killing the master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ process.exit();
+ }
});
});
@@ -107,7 +109,14 @@ exports.listen = function(options, server){
return emitter;
}
-exports.frameStream = function(stream){
+// pass in a raw unframed binary stream, and returns a framed stream for sending and
+// receving strings or other JSON data
+// The second parameter, trusted, indicates to use eval-based parsing which is much faster
+exports.frameStream = function(stream, trusted){
+ var parse = trusted ? function(json){
+ // eval is way faster than JSON.parse on V8 for some reason
+ return eval('(' + json + ')');
+ } : JSON.parse;
var emitter = new process.EventEmitter();
var buffered = [];
var start;
@@ -133,7 +142,7 @@ exports.frameStream = function(stream){
index += part.length;
});
}
- emitter.emit("message", JSON.parse(buffer.toString("utf8", 0, buffer.length)));
+ emitter.emit("message", parse(buffer.toString("utf8", 0, buffer.length)));
start = i + 1;
buffered = [];
}
Vladimir Dronnikov

How do I order to kill children without killing the master?

Please sign in to comment.
Something went wrong with that request. Please try again.