Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Release v0.0.16

  • Loading branch information...
commit f66d1f8556396861c0a21762d4243c3bc846e397 2 parents 22c4830 + ea20f26
@pgte authored
Showing with 7 additions and 9 deletions.
  1. +1 −1  TODO
  2. +6 −8 lib/fugue.js
View
2  TODO
@@ -3,7 +3,7 @@
3. Use fork() to start the workers instead of spawn
4. (DONE)unit / integration tests - any ideas on how to test fugue?
5. review the master / worker protocol for passing in the server socket
-6. review the code that synchronously tries to fetch the file descriptor from the original master into the new respawned master (lib/fugue.js lines 72 - 91) - they're a bit too hacky - try and remove the recvMsg cycle...
+6. (DONE) Review the code that synchronously tries to fetch the file descriptor from the original master into the new respawned master (lib/fugue.js lines 72 - 91) - they're a bit too hacky - try and remove the recvMsg cycle...
7. Monitor request timeouts (as Unicorn does) - only plausible for HTTP Servers, though (??)
8. (DONE) Don't hardcode path for unix socket. Make it a temporary random file and pass it around on environment?
9. Somehow delete master sockets that are not being used. This can be tricky, since master socket paths are passed around to workers and new masters.
View
14 lib/fugue.js
@@ -142,25 +142,23 @@ exports.start = function(server, port, host, worker_count, options) {
netBinding.write(client_socket, request_buffer, 0, request_buffer.length);
var responseBuffer = new Buffer(256);
var length = null;
+ // Node returns length and sets (or not) fd by design as explained in node_net.cc / RecvMsg
do {
length = netBinding.recvMsg(client_socket, responseBuffer, 0, responseBuffer.length)
} while(!netBinding.recvMsg.fd);
log('Got response from server:' + responseBuffer.toString('ascii', 0, length));
- if (netBinding.recvMsg.fd) {
- server_socket = netBinding.recvMsg.fd;
- } else {
- log('Response got no file descriptor... (bad)');
- }
+ server_socket = netBinding.recvMsg.fd;
} catch(error) {
log('Error trying to get server file descriptor: ' + error.message);
}
+
if (!server_socket) {
log('Failed to get socket from original server.');
log('Now I\'m going to try to create one...')
}
-
}
+
if (!server_socket) {
// Now we have to create a socket
@@ -204,7 +202,7 @@ exports.start = function(server, port, host, worker_count, options) {
var spawn_worker = function(worker_idx) {
// prepare environment for worker
var env = {};
- for(var i in process.env){
+ for (var i in process.env) {
env[i] = process.env[i];
}
env._FUGUE_WORKER = "" + (worker_idx + 1);
@@ -212,7 +210,7 @@ exports.start = function(server, port, host, worker_count, options) {
// spawn worker process
var new_worker = workers[worker_idx] = spawn(args[0], args.slice(1), env);
- if(!options.log_file) {
+ if (!options.log_file) {
// if worker does not log into file, pipe the worker output here
var worker_log = function(what) {
console.log("WORKER " + worker_idx + ": " + what.toString());
Please sign in to comment.
Something went wrong with that request. Please try again.