-
Notifications
You must be signed in to change notification settings - Fork 1
/
cluster.js
21 lines (18 loc) · 864 Bytes
/
cluster.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const cluster = require('cluster')
const control = require('strong-cluster-control')
const config = require('./app/config')
const logger = require('./app/logger')
control
.start({ size: config.get('concurrency') })
.on('start', () => logger.info(`Cluster starting`))
.on('stop', () => logger.info(`Cluster stopping`))
.on('setSize', (size) => logger.info(`Cluster size set to ${size} workers`))
.on('restart', () => logger.info(`Cluster restarted`))
.on('resize', (size) => logger.info(`Cluster resized to ${size} workers`))
.on('error', (error) => logger.error(`Cluster error: `, error))
.on('startWorker', (worker) => logger.info(`Cluster worker ${worker.id} started`))
.on('startRestart', (workers) => logger.info(`Cluster restarting workers ${workers}`))
if (cluster.isWorker) {
const server = require('./app/server')
server.start()
}