Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

Commit

Permalink
Prevent STDIN listening when we're a worker process in a cluster (as …
Browse files Browse the repository at this point in the history
…per require('cluster').isWorker)
  • Loading branch information
richtera committed Mar 29, 2012
1 parent a29ac44 commit e5a1fd8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/hookio/hook.js
Expand Up @@ -211,8 +211,16 @@ var Hook = exports.Hook = function (options) {

//
// Allow hook.io to accept STDIN
//
if (!this.ignoreSTDIN && !this.repl && !process.listening) {
// Prevent this to happen when this process is a worker part of a cluster.
//
var isWorker = false;
try {
var cluster = require('cluster');
isWorker = cluster.isWorker;
} catch (e) {
// ignore if cluster is not defined in this version of node.
}
if (!this.ignoreSTDIN && !this.repl && !process.listening && !isWorker) {
process.listening = true;
process.stdin.resume();
process.stdin.setEncoding('utf8');
Expand Down

0 comments on commit e5a1fd8

Please sign in to comment.