(CLI) --disable-trace

This commit is contained in:
Unitech 2017-01-17 15:25:43 +01:00
parent 932f03672f
commit 1896524435
5 changed files with 29 additions and 33 deletions

View File

@ -59,7 +59,8 @@ commander.version(pkg.version)
.option('--no-treekill', 'Only kill the main process, not detached children')
.option('--no-pmx', 'start an app without pmx')
.option('--no-automation', 'start an app without pmx')
.option('--trace [instances_to_trace]', 'enable transaction tracing with keymetrics', false)
.option('--trace', 'enable transaction tracing with km')
.option('--disable-trace', 'disable transaction tracing with km')
.usage('[cmd] app');
commander.on('--help', function() {
@ -729,7 +730,7 @@ commander.command('logs [id|name]')
if (cmd.err === true)
exclusive = 'err';
if (cmd.nostream === true)
pm2.printLogs(id, line, raw, timestamp, exclusive);
else if (cmd.json === true)

View File

@ -108,16 +108,14 @@ var API = module.exports = function(opts) {
this.gl_interact_infos = null;
this.gl_is_km_linked = false;
fs.readFile(conf.INTERACTOR_PID_PATH, function(err, data) {
if (err) return false;
try {
var pid = parseInt(data.toString().trim());
process.kill(pid, 0);
that.gl_is_km_linked = true;
} catch(e) {
that.gl_is_km_linked = false;
}
});
try {
var pid = fs.readFileSync(conf.INTERACTOR_PID_PATH);
pid = parseInt(pid.toString().trim());
process.kill(pid, 0);
that.gl_is_km_linked = true;
} catch(e) {
that.gl_is_km_linked = false;
}
KMDaemon.getInteractInfo(this._conf, function(i_err, interact) {
that.gl_interact_infos = interact;
@ -783,8 +781,7 @@ API.prototype._startScript = function(script, opts, cb) {
util._extend(resolved_paths.env, additional_env);
// Is KM linked?
if (that.gl_is_km_linked != false)
resolved_paths.km_link = true;
resolved_paths.km_link = that.gl_is_km_linked;
that.Client.executeRemote('prepare', resolved_paths, function(err, data) {
if (err) {
@ -1014,8 +1011,7 @@ API.prototype._startJson = function(file, opts, action, pipe, cb) {
delete resolved_paths.env.current_conf;
// Is KM linked?
if (that.gl_is_km_linked != false)
resolved_paths.km_link = true;
resolved_paths.km_link = that.gl_is_km_linked;
that.Client.executeRemote('prepare', resolved_paths, function(err, data) {
if (err) {
@ -1190,6 +1186,9 @@ API.prototype._operate = function(action_name, process_name, envs, cb) {
envs = {
current_conf : _conf
}
// Is KM linked?
envs.current_conf.km_link = that.gl_is_km_linked;
}
/**

View File

@ -167,9 +167,13 @@
"post_update": {
"type": "array"
},
"disable_trace": {
"type": [
"boolean"
]
},
"trace": {
"type": [
"number",
"boolean"
]
}

View File

@ -501,6 +501,7 @@ Common.mergeEnvironmentVariables = function(app_env, env_name, deploy_conf) {
/**
* This function will resolve paths, option and environment
* CALLED before 'prepare' God call (=> PROCESS INITIALIZATION)
* @method resolveAppAttributes
* @param {Object} opts
* @param {Object} opts.cwd
@ -521,7 +522,8 @@ Common.resolveAppAttributes = function(opts, legacy_app) {
/**
* Verify configurations.
* Verify configurations
* Called on EVERY Operation (start/restart/reload/stop...)
* @param {Array} appConfs
* @returns {Array}
*/
@ -538,6 +540,11 @@ Common.verifyConfs = function(appConfs){
for (var i = 0; i < appConfs.length; i++) {
var app = appConfs[i];
if (app.disable_trace) {
app.trace = false
delete app.disable_trace;
}
// Warn deprecates.
checkDeprecates(app);

View File

@ -361,9 +361,6 @@ God.prepare = function prepare(env, cb) {
var arr = [];
var instance_id = 0;
// pick a number of worker that will have tracing enabled
var workerTraced = typeof(env.trace === 'number') ? env.trace : 1;
(function ex(i) {
if (i <= 0) {
if (cb) return cb(null, arr);
@ -376,18 +373,6 @@ God.prepare = function prepare(env, cb) {
if (env.env && env.env.vizion_running)
env.env.vizion_running = false;
// if the tracing is enabled
if (env.trace !== undefined && env.trace !== false) {
// check if we enabled trace in the number provided of worker
if (workerTraced > 0) {
workerTraced--;
env.trace = true;
}
// or disable it
else
env.trace = false;
}
return God.executeApp(Utility.clone(env), function(err, clu) {
if (err) return ex(i - 1);
arr.push(Utility.clone(clu));