codecombat/multicore.coffee

15 lines
439 B
CoffeeScript
Raw Normal View History

2014-06-17 13:31:16 -04:00
cluster = require 'cluster'
numCPUs = require('os').cpus().length
if cluster.isMaster
for i in [0...numCPUs]
cluster.fork()
cluster.on 'exit', (worker, code, signal) ->
2014-11-24 20:07:29 -05:00
console.log 'worker ' + worker.id + ' died'
2014-06-17 13:31:16 -04:00
cluster.fork()
else
require('coffee-script')
require('coffee-script/register')
server = require('./server')
server.startServer()