From 95eade4268d99f54c458393da3ef9c25247223dc Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 16 Apr 2015 15:29:13 -0700 Subject: [PATCH] Sending HipChat Tower messages upon server death, I hope. --- multicore.coffee | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/multicore.coffee b/multicore.coffee index d9a560513..2a78205d7 100644 --- a/multicore.coffee +++ b/multicore.coffee @@ -2,13 +2,19 @@ cluster = require 'cluster' numCPUs = require('os').cpus().length if cluster.isMaster - for i in [0...numCPUs] - cluster.fork() - cluster.on 'exit', (worker, code, signal) -> - console.log 'worker ' + worker.id + ' died' - cluster.fork() + for i in [0...numCPUs] + cluster.fork() + cluster.on 'exit', (worker, code, signal) -> + message = "Worker #{worker.id} died! Heart attack takin' a dump." + console.log message + try + hipchat = require './server/hipchat' + hipchat.sendHipChatMessage(message, ['tower'], {papertrail: true}) + catch error + console.log "Couldn't send HipChat message on server death:", error + cluster.fork() else - require('coffee-script') - require('coffee-script/register') - server = require('./server') - server.startServer() + require('coffee-script') + require('coffee-script/register') + server = require('./server') + server.startServer()