Better messages - pm2 logs display also internal logs

This commit is contained in:
tknew2 2014-09-11 18:04:33 +02:00
parent 0a713632dc
commit decdc81b95
7 changed files with 25 additions and 27 deletions

View File

@ -1399,6 +1399,8 @@ function fallbackLogStream(id) {
exitCli(cst.ERROR_EXIT);
}
Log.stream(cst.PM2_LOG_FILE_PATH, 'PM2');
printOut('########### Starting streaming logs for [%s] process', id || 'all');
list.forEach(function(proc) {
if ((!id || (id && !isNaN(parseInt(id)) && proc.pm_id == id)) ||

View File

@ -55,7 +55,7 @@ require('./Watcher')(God);
* @return
*/
God.handleExit = function handleExit(clu, exit_code) {
console.log('Script %s %s exit', clu.pm2_env.pm_exec_path, clu.pm2_env.pm_id);
console.log('App name:%s id:%s exited', clu.pm2_env.name, clu.pm2_env.pm_id);
var proc = this.clusters_db[clu.pm2_env.pm_id];
@ -202,6 +202,7 @@ God.executeApp = function executeApp(env, cb) {
God.bus.emit('process:online', {process : Common.serialize(proc)});
console.log('App name:%s id:%s online', proc.pm2_env.name, proc.pm2_env.pm_id);
if (cb) cb(null, clu);
return false;
});
@ -233,7 +234,7 @@ God.executeApp = function executeApp(env, cb) {
clu.once('online', function cluOnline() {
proc.pm2_env.status = cst.ONLINE_STATUS;
console.log('%s - id%s worker online', proc.pm2_env.pm_exec_path, proc.pm2_env.pm_id);
console.log('App name:%s id:%s online', proc.pm2_env.name, proc.pm2_env.pm_id);
God.bus.emit('process:online', { process : Common.serialize(proc) });

View File

@ -311,13 +311,12 @@ module.exports = function(God) {
util._extend(proc.pm2_env.env, opts.env);
if (proc.pm2_env.status == cst.ONLINE_STATUS) {
debug('[restart] process already online, killing it for auto restart');
God.killProcess(proc.process.pid, function() {
setTimeout(function() {
return cb(null, God.getFormatedProcesses());
}, 100);
return false;
God.stopProcessId(id, function(err) {
proc.pm2_env.restart_time += 1;
return God.startProcessId(id, cb);
});
return false;
}
else {
debug('[restart] process not online, starting it');

View File

@ -35,7 +35,9 @@ module.exports = function ClusterMode(God) {
// return cb(God.logAndGenerateError('Script ' + env_copy.pm_exec_path + ' missing'), {});
// }
console.log('Entering in node wrap logic (cluster_mode) for script %s', env_copy.pm_exec_path);
console.log('Starting execution sequence in -cluster mode- for app name:%s id:%s',
env_copy.name,
env_copy.pm_id);
if (env_copy.node_args && Array.isArray(env_copy.node_args)) {
cluster.settings.execArgv = env_copy.node_args;

View File

@ -31,7 +31,9 @@ module.exports = function ForkMode(God) {
var command = '';
var args = [];
console.log('Entering in fork mode');
console.log('Starting execution sequence in -fork mode- for app name:%s id:%s',
pm2_env.name,
pm2_env.pm_id);
var spawn = require('child_process').spawn;
var interpreter = pm2_env.exec_interpreter || 'node';

View File

@ -179,16 +179,16 @@ module.exports = function(God) {
God.processIsDead = function(pid, cb) {
if (!pid) return cb({type : 'param:missing', msg : 'no pid passed'});
var timeout;
var timeout = null;
var timer = setInterval(function() {
if (God.checkProcess(pid) === false) {
console.log('process with pid %d successfully killed', pid);
console.log('Process with pid %d killed', pid);
clearTimeout(timeout);
clearInterval(timer);
return cb(null, true);
}
console.log('process with pid %d still not killed, retrying...', pid);
console.log('Process with pid %d still not killed, retrying...', pid);
return false;
}, 50);

View File

@ -57,7 +57,7 @@ function softReload(God, id, cb) {
// The new worker is up but does not need to listen.
new_worker.emit('listening');
}
}
};
new_worker.on('message', onmessage);
@ -65,16 +65,12 @@ function softReload(God, id, cb) {
new_worker.once('listening', function() {
new_worker.removeListener('message', onmessage);
clearTimeout(timeout_1);
console.log('%s - id%d worker listening',
new_worker.pm2_env.pm_exec_path,
new_worker.pm2_env.pm_id);
console.log('-reload- New worker listening');
old_worker.once('disconnect', function() {
clearTimeout(timeout_2);
console.log('%s - id%s worker disconnect',
old_worker.pm2_env.pm_exec_path,
old_worker.pm2_env.pm_id);
console.log('-reload- Old worker disconnected');
return God.deleteProcessId(t_key, cb);
});
timeout_2 = setTimeout(function() {
@ -131,6 +127,7 @@ function hardReload(God, id, cb) {
old_worker.pm2_env.pm_id = t_key;
console.log('-reload- Creating a new process waiting for connections');
God.executeApp(new_env, function(err, new_worker) {
if (err) return cb(err);
@ -141,15 +138,10 @@ function hardReload(God, id, cb) {
// Bind to know when the new process is up
new_worker.once('listening', function() {
clearTimeout(timer);
console.log('%s - id%d worker listening',
new_worker.pm2_env.pm_exec_path,
new_worker.pm2_env.pm_id);
console.log('-reload- New worker listening');
//old_worker.once('message', function(type) {
old_worker.once('disconnect', function() {
console.log('%s - id%s worker disconnect',
old_worker.pm2_env.pm_exec_path,
old_worker.pm2_env.pm_id);
console.log('-reload- Old worker disconnected');
God.deleteProcessId(t_key, cb);
});
try {