-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tap, touch, make sure all our processes respect SIGTERM
- Loading branch information
Showing
12 changed files
with
268 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
.nyc_output | ||
.vagrant | ||
node_modules | ||
npm-debug.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.nyc_output | ||
package-lock.json | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
var cluster = require('cluster'); | ||
|
||
function createWorker() { | ||
function createWorker(i) { | ||
var worker = cluster.fork(); | ||
worker.on('message', function (msg) { | ||
console.log('Message from worker:', msg); | ||
console.log('Message from worker', i, ':', msg); | ||
}); | ||
worker.on('disconnect', function () { | ||
console.log('Worker disconnected', i); | ||
}); | ||
return worker; | ||
} | ||
|
||
var workers = []; | ||
|
||
if (cluster.isMaster) { | ||
for (var i = 0; i < 2; i += 1) { | ||
console.log('Forking worker', i); | ||
createWorker(); | ||
workers.push(createWorker(i)); | ||
} | ||
process.on('SIGTERM', function () { | ||
console.log('Master received SIGTERM'); | ||
workers.forEach(function (worker) { | ||
worker.disconnect(); | ||
}); | ||
}); | ||
} else { | ||
console.log('Worker started.'); | ||
process.send('Hello'); | ||
require('./server'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require('http').createServer().listen(0); | ||
console.log(process.pid); | ||
process.on('SIGTERM', function () { process.exit(); }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.