log emit notifications

This commit is contained in:
tknew2 2013-12-22 17:37:13 +01:00
parent 625e0af17c
commit 0fe158737c
2 changed files with 14 additions and 0 deletions

View File

@ -116,6 +116,12 @@ function nodeApp(pm2_env, cb){
case 'uncaughtException':
God.bus.emit('process:exception', {process : clu, msg : msg.stack});
break;
case 'log:out':
God.bus.emit('log:out', {process : clu, data : msg.data});
break;
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);
}

View File

@ -80,6 +80,10 @@ function exec(script, outFile, errFile) {
process.stderr.write = (function(write) {
return function(string, encoding, fd) {
stderr.write(string);
process.send({
type : 'log:out',
data : string
});
};
}
)(process.stderr.write);
@ -87,6 +91,10 @@ function exec(script, outFile, errFile) {
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
stdout.write(string);
process.send({
type : 'log:err',
data : string
});
};
})(process.stdout.write);