Permalink
Browse files

On second thought, let's keep cluster.js and actually start using it.

  • Loading branch information...
1 parent 98c3e34 commit 8265ca3b3ef509fde44e0f8fb3be5910c7eb4220 @rgrove committed Jul 24, 2016
Showing with 23 additions and 3 deletions.
  1. +20 −0 cluster.js
  2. 0 web.js → index.js
  3. +1 −1 package.json
  4. +1 −1 test/test.redirect.js
  5. +1 −1 test/test.routes.js
View
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+'use strict';
+
+const cluster = require('cluster');
+
+if (cluster.isMaster) {
+ let workerCount = +(process.env.WORKERS || require('os').cpus().length);
+
+ while (workerCount--) {
+ cluster.fork();
+ }
+
+ cluster.on('exit', deadWorker => {
+ let worker = cluster.fork();
+ console.log(`Worker ${deadWorker.process.pid} replaced by ${worker.process.pid}`);
+ });
+} else {
+ console.log(`Starting worker ${process.pid}`);
+ require('./');
+}
View
File renamed without changes.
View
@@ -22,7 +22,7 @@
"clean-fixtures": "scripts/clean-fixtures.js test/fixtures/*.json",
"lint": "eslint .",
"record-fixtures": "NOCK_BACK_MODE=record npm test && npm run-script clean-fixtures",
- "start": "NODE_ENV=development nodemon web.js",
+ "start": "NODE_ENV=development nodemon",
"test": "NODE_ENV=test mocha -R dot test/**/test.*.js"
}
}
@@ -5,7 +5,7 @@ const assert = require('chai').assert;
const nock = require('nock');
const request = require('supertest');
-const app = require('../web');
+const app = require('../');
const helpers = require('./helpers');
const agent = request.agent(app);
View
@@ -5,7 +5,7 @@ const assert = require('chai').assert;
const nock = require('nock');
const request = require('supertest');
-const app = require('../web');
+const app = require('../');
const helpers = require('./helpers');
const agent = request.agent(app);

0 comments on commit 8265ca3

Please sign in to comment.