From 6630b1536cbb1bd5cb9b0754bd222b3c2554977f Mon Sep 17 00:00:00 2001 From: Ben Postlethwaite Date: Sun, 22 Dec 2013 13:30:58 -0500 Subject: [PATCH 1/2] add pm2_id to external msgs to link msg to sending process --- lib/God.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/God.js b/lib/God.js index aeff3838..6d2b8efc 100644 --- a/lib/God.js +++ b/lib/God.js @@ -122,8 +122,10 @@ function nodeApp(pm2_env, cb){ case 'log:err': God.bus.emit('log:err', {process : clu, data : msg.data}); break; - default: // Permits to send message to external from the app - God.bus.emit(msg.type ? msg.type : 'msg', msg); + default: // Permits to send message to external from the app - include pm2_id for identification. + God.bus.emit(msg.type ? msg.type : 'msg', { + pm_id: ("pm_id" in clu.pm2_env) ? clu.pm2_env.pm_id : "" + , msg: msg }); } }); From 3d67e50fca0d730223635903b2d76b99944dec69 Mon Sep 17 00:00:00 2001 From: Ben Postlethwaite Date: Sun, 22 Dec 2013 21:54:06 -0500 Subject: [PATCH 2/2] more consistent external bus msg routing --- lib/God.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/God.js b/lib/God.js index 6d2b8efc..f1d3428a 100644 --- a/lib/God.js +++ b/lib/God.js @@ -114,7 +114,7 @@ function nodeApp(pm2_env, cb){ clu.on('message', function(msg) { switch (msg.type) { case 'uncaughtException': - God.bus.emit('process:exception', {process : clu, msg : msg.stack, err : msg.err}); + God.bus.emit('process:exception', {process : clu, data : msg.stack, err : msg.err}); break; case 'log:out': God.bus.emit('log:out', {process : clu, data : msg.data}); @@ -122,10 +122,8 @@ function nodeApp(pm2_env, cb){ case 'log:err': God.bus.emit('log:err', {process : clu, data : msg.data}); break; - default: // Permits to send message to external from the app - include pm2_id for identification. - God.bus.emit(msg.type ? msg.type : 'msg', { - pm_id: ("pm_id" in clu.pm2_env) ? clu.pm2_env.pm_id : "" - , msg: msg }); + default: // Permits to send message to external from the app + God.bus.emit(msg.type ? msg.type : 'process:msg', {process : clu, data : msg }); } });