Skip to content

Commit

Permalink
Added workerPidfile() to bin/connect
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jun 16, 2010
1 parent 7a32df5 commit 26662c6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions bin/connect
Expand Up @@ -191,8 +191,7 @@ function status(pid) {
} else {
status(getpid(env.pidfile));
for (var i = 0; i < workers; ++i) {
var pidfile = env.pidfile.replace('.pid', '.worker.' + i + '.pid');
status(getpid(pidfile));
status(getpid(workerPidfile(i)));
}
}
}
Expand All @@ -216,8 +215,7 @@ function stop(pid){
} else {
stop(getpid(env.pidfile));
for (var i = 0; i < workers; ++i) {
var pidfile = env.pidfile.replace('.pid', '.worker.' + i + '.pid');
stop(getpid(pidfile));
stop(getpid(workerPidfile(i)));
}
}
}
Expand All @@ -237,6 +235,17 @@ function exists(path) {
}
}

/**
* Return worker pidfile for the given index.
*
* @param {Number} i
* @return {String}
*/

function workerPidfile(i){
return env.pidfile.replace('.pid', '.worker.' + i + '.pid');
}

/**
* Require application module at the given path,
* which must be an instanceof net.Server, otherwise
Expand Down Expand Up @@ -358,8 +367,7 @@ function start() {
}

// Write out worker pids
var pidfile = env.pidfile.replace('.pid', '.worker.' + i + '.pid');
fs.writeFileSync(pidfile, child.pid.toString(), 'ascii');
fs.writeFileSync(workerPidfile(i), child.pid.toString(), 'ascii');

child.stdin.write(JSON.stringify(env), 'ascii', fd);

Expand Down

0 comments on commit 26662c6

Please sign in to comment.