Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

notify exceptions

  • Loading branch information...
commit a974cee31b5f651e511e3a3c2ea20e3f90560a25 1 parent 26f2c1e
@tj authored
View
1  example.js
@@ -8,6 +8,7 @@ var http = require('http')
, live = require('./');
var server = http.createServer(function(req, res){
+ if (Math.random() > 0.95) throw new Error('something broke!');
res.end('Hello World');
});
View
14 lib/cluster-live.js
@@ -120,6 +120,10 @@ function live(port, host, options) {
master.on('worker killed', function(worker){
sockets.emit('worker killed', stripWorker(worker));
});
+
+ master.on('worker exception', function(worker, err){
+ sockets.emit('worker exception', stripWorker(worker), stripError(err));
+ });
master.on('worker', function(worker){
sockets.emit('worker spawned', stripWorker(worker));
@@ -141,6 +145,16 @@ function live(port, host, options) {
};
/**
+ * Prep error for JSON.
+ */
+
+function stripError(err) {
+ return {
+ message: err.message
+ };
+}
+
+/**
* Prep master for JSON.
*/
View
5 lib/public/javascripts/main.js
@@ -56,6 +56,11 @@ window.onload = function(){
worker.stopReporting().overlay('killed');
});
+ cluster.on('worker exception', function(_worker, err){
+ var worker = getWorker(_worker);
+ utils.notify('worker #' + worker.id + ': ' + err.message);
+ });
+
cluster.on('worker removed', function(_worker){
var worker = getWorker(_worker);
utils.notify('worker #' + worker.id + ' removed');
Please sign in to comment.
Something went wrong with that request. Please try again.