flatten output

This commit is contained in:
tknew2 2014-08-14 14:00:20 +02:00
parent 58292a488c
commit 67a00e5fd4
4 changed files with 35 additions and 34 deletions

24
bin/pm2
View File

@ -508,15 +508,15 @@ process.once('satan:client:ready', function() {
});
})();
(function testHarmony() {
//
// Harmony test
//
try {
var assert = require('assert')
, s = new Set();
s.add('a');
assert.ok(s.has('a'));
console.log('● ES6 mode'.green);
} catch(e) {}
})();
// (function testHarmony() {
// //
// // Harmony test
// //
// try {
// var assert = require('assert')
// , s = new Set();
// s.add('a');
// assert.ok(s.has('a'));
// console.log('● ES6 mode'.green);
// } catch(e) {}
// })();

View File

@ -36,8 +36,8 @@ var default_conf = {
DEBUG : process.env.PM2_DEBUG || false,
WEB_INTERFACE : parseInt(process.env.PM2_API_PORT) || 9615,
MODIFY_REQUIRE : process.env.PM2_MODIFY_REQUIRE || false,
PREFIX_MSG : '\x1B[32mPM2 \x1B[39m',
PREFIX_MSG_ERR : '\x1B[31mPM2 [ERROR] \x1B[39m',
PREFIX_MSG : '\x1B[32m[PM2] \x1B[39m',
PREFIX_MSG_ERR : '\x1B[31m[PM2] [ERROR] \x1B[39m',
SAMPLE_FILE_PATH : '../lib/sample.json',
CENTOS_STARTUP_SCRIPT : '../lib/scripts/pm2-init-centos.sh',

View File

@ -540,7 +540,7 @@ CLI.resetMetaProcess = function(process_name, cb) {
async.eachLimit(ids, 4, function(id, next) {
Satan.executeRemote('resetMetaProcessId', id, function(err, res) {
if (err) console.error(err);
printOut('Reseting meta for process id %d', id);
printOut(cst.PREFIX_MSG + 'Reseting meta for process id %d', id);
return next();
});
}, function(err) {
@ -962,7 +962,7 @@ CLI._restartAll = function(cb) {
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
if (list && list.length === 0) {
printError('No process launched');
printError(cst.PREFIX_MSG + 'No process launched');
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
@ -971,7 +971,7 @@ CLI._restartAll = function(cb) {
var proc = processes[0];
if (proc == null) {
printOut(cst.PREFIX_MSG + 'Process restarted...');
printOut(cst.PREFIX_MSG + 'All processes has been restarted');
return cb ? cb(null, processes) : setTimeout(speedList, 1000);
}
Satan.executeRemote('restartProcessId', proc.pm2_env.pm_id, function(err, res) {
@ -1004,35 +1004,35 @@ CLI.delete = function(process_name, jsonVia, cb) {
process_name = process_name.toString();
}
printOut(cst.PREFIX_MSG + 'Deleting ' + process_name);
if (jsonVia == 'pipe')
return CLI.actionFromJson('deleteProcessName', process_name, 'pipe');
if (process_name.indexOf('.json') > 0)
return CLI.actionFromJson('deleteProcessName', process_name, 'file');
else if (process_name == 'all') {
printOut(cst.PREFIX_MSG + 'Stopping and deleting all processes');
Satan.executeRemote('deleteAll', {}, function(err, list) {
if (err) {
printError(err);
printError(cst.PREFIX_MSG_ERR + err);
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
printOut(cst.PREFIX_MSG + 'All processes has been stopped and deleted');
return cb ? cb(null, list) : speedList();
});
}
else if (!isNaN(parseInt(process_name))) {
printOut('Stopping and deleting process by id : %s', process_name);
Satan.executeRemote('deleteProcessId', process_name, function(err, list) {
if (err) {
printError(err);
printError(cst.PREFIX_MSG_ERR + err);
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
return cb ? cb(null, list) : speedList();
});
}
else {
printOut(cst.PREFIX_MSG + 'Stopping and deleting process by name %s', process_name);
Satan.executeRemote('deleteProcessName', process_name, function(err, list) {
if (err) {
printError(err);
printError(cst.PREFIX_MSG_ERR + err);
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
return cb ? cb(null, list) : speedList();
@ -1045,6 +1045,8 @@ CLI.stop = function(process_name, cb) {
if (typeof(process_name) === 'number')
process_name = process_name.toString();
printOut(cst.PREFIX_MSG + 'Stopping ' + process_name);
if (process_name == "-") {
process.stdin.resume();
process.stdin.setEncoding('utf8');
@ -1059,7 +1061,6 @@ CLI.stop = function(process_name, cb) {
else if (isNaN(parseInt(process_name))) {
CLI._stopProcessName(process_name, cb);
} else {
printOut(cst.PREFIX_MSG + 'Stopping process by id ' + process_name);
CLI._stopId(process_name, cb);
}
};
@ -1072,9 +1073,10 @@ CLI.stop = function(process_name, cb) {
CLI._stopAll = function(cb) {
Satan.executeRemote('stopAll', {}, function(err, list) {
if (err) {
printError(err);
printError(cst.PREFIX_MSG_ERR + err);
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
printOut(cst.PREFIX_MSG + 'All processes stopped');
return cb ? cb(null, list) : speedList();
});
};
@ -1088,7 +1090,7 @@ CLI._stopAll = function(cb) {
CLI._stopProcessName = function(name, cb) {
Satan.executeRemote('stopProcessName', name, function(err, list) {
if (err) {
printError(err);
printError(cst.PREFIX_MSG_ERR + err);
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
printOut(cst.PREFIX_MSG + 'Stopping process by name ' + name);
@ -1105,10 +1107,10 @@ CLI._stopProcessName = function(name, cb) {
CLI._stopId = function(pm2_id, cb) {
Satan.executeRemote('stopProcessId', pm2_id, function(err, list) {
if (err) {
printError(err);
printError(cst.PREFIX_MSG_ERR + err);
return cb ? cb({msg:err}) : exitCli(cst.ERROR_EXIT);
}
printOut(cst.PREFIX_MSG + ' Process stopped');
printOut(cst.PREFIX_MSG + 'Process %d stopped', pm2_id);
return cb ? cb(null, list) : speedList();
});
};
@ -1186,6 +1188,7 @@ CLI.flush = function(cb) {
fs.openSync(l.pm2_env.pm_out_log_path, 'w');
fs.openSync(l.pm2_env.pm_err_log_path, 'w');
});
printOut(cst.PREFIX_MSG + 'Logs flushed');
return cb ? cb(null, list) : exitCli(cst.SUCCESS_EXIT);
});
};
@ -1368,7 +1371,7 @@ CLI.ilogs = function() {
* @return
*/
CLI.killDaemon = function(cb) {
printOut(cst.PREFIX_MSG + 'Killing pm2...');
printOut(cst.PREFIX_MSG + 'Stopping PM2');
Satan.executeRemote('getMonitorData', {}, function(err, list) {
if (err) {
@ -1394,7 +1397,7 @@ CLI.killDaemon = function(cb) {
if (cb) return cb({msg:err});
else exitCli(cst.ERROR_EXIT);
}
console.info('PM2 stopped');
console.info(cst.PREFIX_MSG + 'PM2 stopped');
return cb ? cb(null, res) : exitCli(cst.SUCCESS_EXIT);
});
});

View File

@ -130,8 +130,6 @@ function launchOrAttach(infos, cb) {
InteractorDaemonizer.daemonize = function(infos, cb) {
var InteractorJS = path.resolve(path.dirname(module.filename), 'Daemon.js');
console.log('Launching interactor');
var out = fs.openSync(cst.INTERACTOR_LOG_FILE_PATH, 'a'),
err = fs.openSync(cst.INTERACTOR_LOG_FILE_PATH, 'a');
@ -154,10 +152,10 @@ InteractorDaemonizer.daemonize = function(infos, cb) {
child.once('message', function(msg) {
process.emit('interactor:daemon:ready');
console.log(msg);
//console.log(msg);
child.disconnect();
console.log(chalk.cyan.bold('[Keymetrics.io]') + ' Log: %s | Conf: %s | PID: %s', cst.INTERACTOR_LOG_FILE_PATH,
console.log(chalk.cyan('[Keymetrics.io]') + ' Launched - Log: %s | Conf: %s | PID: %s', cst.INTERACTOR_LOG_FILE_PATH,
cst.INTERACTION_CONF,
cst.INTERACTOR_PID_PATH);
return setTimeout(function() {cb(null, child)}, 100);