diff --git a/constants.js b/constants.js index 3c21e4c08..48d7a9a09 100644 --- a/constants.js +++ b/constants.js @@ -55,7 +55,12 @@ var csts = { LOW_MEMORY_ENVIRONMENT : process.env.PM2_OPTIMIZE_MEMORY || false, - KEYMETRICS_ROOT_URL : process.env.KEYMETRICS_NODE || 'root.keymetrics.io', + MACHINE_NAME : process.env.INSTANCE_NAME || process.env.MACHINE_NAME, + SECRET_KEY : process.env.KEYMETRICS_SECRET || process.env.PM2_SECRET_KEY || process.env.SECRET_KEY, + PUBLIC_KEY : process.env.KEYMETRICS_PUBLIC || process.env.PM2_PUBLIC_KEY || process.env.PUBLIC_KEY, + KEYMETRICS_ROOT_URL : process.env.KEYMETRICS_NODE || process.env.ROOT_URL || process.env.INFO_NODE || 'root.keymetrics.io', + + KEYMETRICS_BANNER : '../lib/motd', KEYMETRICS_UPDATE : '../lib/motd.update', DEFAULT_MODULE_JSON : 'package.json', diff --git a/lib/API.js b/lib/API.js index c1a23f369..aaea293f0 100644 --- a/lib/API.js +++ b/lib/API.js @@ -42,9 +42,9 @@ var IMMUTABLE_MSG = chalk.bold.blue('Use --update-env to update environment vari * @param {String} [opts.pm2_home=[]] pm2 directory for log, pids, socket files * @param {Boolean} [opts.independent=false] unique PM2 instance (random pm2_home) * @param {Boolean} [opts.daemon_mode=true] should be called in the same process or not - * @param {String} [opts.public_key=null] keymetrics bucket public key - * @param {String} [opts.secret_key=null] keymetrics bucket secret key - * @param {String} [opts.machine_name=null] keymetrics instance name + * @param {String} [opts.public_key=null] pm2 plus bucket public key + * @param {String} [opts.secret_key=null] pm2 plus bucket secret key + * @param {String} [opts.machine_name=null] pm2 plus instance name */ class API { @@ -54,9 +54,9 @@ class API { this.daemon_mode = typeof(opts.daemon_mode) == 'undefined' ? true : opts.daemon_mode; this.pm2_home = conf.PM2_ROOT_PATH; - this.public_key = process.env.KEYMETRICS_SECRET || opts.public_key || null; - this.secret_key = process.env.KEYMETRICS_PUBLIC || opts.secret_key || null; - this.machine_name = process.env.INSTANCE_NAME || opts.machine_name || null + this.public_key = conf.PUBLIC_KEY || opts.public_key || null; + this.secret_key = conf.SECRET_KEY || opts.secret_key || null; + this.machine_name = conf.MACHINE_NAME || opts.machine_name || null /** * CWD resolution @@ -372,7 +372,7 @@ class API { that.Client.executeRemote('notifyKillPM2', {}, function() {}); that.getVersion(function(err, new_version) { - // If not linked to keymetrics, and update pm2 to latest, display motd.update + // If not linked to PM2 plus, and update PM2 to latest, display motd.update if (!that.gl_is_km_linked && !err && (pkg.version != new_version)) { var dt = fs.readFileSync(path.join(__dirname, that._conf.KEYMETRICS_UPDATE)); console.log(dt.toString()); diff --git a/lib/API/Interaction.js b/lib/API/Interaction.js index 8d9557d4f..3181127ac 100644 --- a/lib/API/Interaction.js +++ b/lib/API/Interaction.js @@ -80,16 +80,16 @@ module.exports = function(CLI) { var that = this; if (cmd == 'stop' || cmd == 'kill') { - console.log(chalk.cyan('[Keymetrics.io]') + ' Stopping agent...'); + console.log(chalk.cyan('[PM2 agent]') + ' Stopping agent...'); that.killInteract(function() { - console.log(chalk.cyan('[Keymetrics.io]') + ' Stopped'); + console.log(chalk.cyan('[PM2 agent]') + ' Stopped'); return process.exit(cst.SUCCESS_EXIT); }); return false; } if (cmd == 'info') { - console.log(chalk.cyan('[Keymetrics.io]') + ' Getting agent information...'); + console.log(chalk.cyan('[PM2 agent]') + ' Getting agent information...'); that.interactInfos(function(err, infos) { if (err) { console.error(err.message); @@ -106,10 +106,10 @@ module.exports = function(CLI) { try { fs.unlinkSync(cst.INTERACTION_CONF); } catch(e) { - console.log(chalk.cyan('[Keymetrics.io]') + ' No interaction config file found'); + console.log(chalk.cyan('[PM2 agent]') + ' No interaction config file found'); return process.exit(cst.SUCCESS_EXIT); } - console.log(chalk.cyan('[Keymetrics.io]') + ' Agent interaction ended'); + console.log(chalk.cyan('[PM2 agent]') + ' Agent interaction ended'); return process.exit(cst.SUCCESS_EXIT); }); return false; @@ -132,7 +132,7 @@ module.exports = function(CLI) { } if (cmd && !public_key) { - console.error(chalk.cyan('[Keymetrics.io]') + ' Command [%s] unknown or missing public key', cmd); + console.error(chalk.cyan('[PM2 agent]') + ' Command [%s] unknown or missing public key', cmd); return process.exit(cst.ERROR_EXIT); } diff --git a/lib/binaries/Runtime.js b/lib/binaries/Runtime.js index 99c6cb193..0ad94aeef 100644 --- a/lib/binaries/Runtime.js +++ b/lib/binaries/Runtime.js @@ -20,9 +20,9 @@ commander.version(pkg.version) .option('--auto-manage', 'keep application online after command exit') .option('--fast-boot', 'boot app faster by keeping pm2 runtime online in background (effective at second exit/start)') .option('--web [port]', 'launch process web api on [port] default to 9615') - .option('--secret [key]', 'keymetrics secret key') - .option('--public [key]', 'keymetrics public key') - .option('--machine-name [name]', 'keymetrics machine name') + .option('--secret [key]', 'PM2 plus secret key') + .option('--public [key]', 'PM2 plus public key') + .option('--machine-name [name]', 'PM2 plus machine name') .option('--env [name]', 'select env_[name] env variables in process config file') .option('--watch', 'Watch and Restart') .option('-i --instances ', 'launch [number] instances with load-balancer') @@ -32,9 +32,9 @@ commander.command('*') .action(function(cmd){ pm2 = new PM2.custom({ pm2_home : path.join(process.env.HOME, '.pm3'), - secret_key : process.env.KEYMETRICS_SECRET || commander.secret, - public_key : process.env.KEYMETRICS_PUBLIC || commander.public, - machine_name : process.env.INSTANCE_NAME || commander.machineName + secret_key : cst.SECRET_KEY || commander.secret, + public_key : cst.PUBLIC_KEY || commander.public, + machine_name : cst.MACHINE_NAME || commander.machineName }); pm2.connect(function() { diff --git a/lib/binaries/Runtime4Docker.js b/lib/binaries/Runtime4Docker.js index ee956bfe5..837daa4b3 100644 --- a/lib/binaries/Runtime4Docker.js +++ b/lib/binaries/Runtime4Docker.js @@ -17,15 +17,15 @@ process.env.PM2_DISCRETE_MODE = true; commander.version(pkg.version) .description('pm2-runtime is a drop-in replacement Node.js binary for containers') .option('-i --instances ', 'launch [number] of processes automatically load-balanced. Increase overall performances and performance stability.') - .option('--secret [key]', '[MONITORING] keymetrics secret key') + .option('--secret [key]', '[MONITORING] PM2 plus secret key') .option('--no-autorestart', 'start an app without automatic restart') .option('--node-args ', 'space delimited arguments to pass to node in cluster mode - e.g. --node-args="--debug=7001 --trace-deprecation"') .option('-n --name ', 'set a for script') .option('--max-memory-restart ', 'specify max memory amount used to autorestart (in octet or use syntax like 100M)') .option('-c --cron ', 'restart a running process based on a cron pattern') .option('--interpreter ', 'the interpreter pm2 should use for executing app (bash, python...)') - .option('--public [key]', '[MONITORING] keymetrics public key') - .option('--machine-name [name]', '[MONITORING] keymetrics machine name') + .option('--public [key]', '[MONITORING] PM2 plus public key') + .option('--machine-name [name]', '[MONITORING] PM2 plus machine name') .option('--trace', 'enable transaction tracing with km') .option('--v8', 'enable v8 data collecting') .option('--format', 'output logs formated like key=val') @@ -65,9 +65,9 @@ var Runtime = { instanciate : function(cmd) { this.pm2 = new PM2.custom({ pm2_home : process.env.PM2_HOME || path.join(process.env.HOME, '.pm2'), - secret_key : process.env.KEYMETRICS_SECRET || commander.secret, - public_key : process.env.KEYMETRICS_PUBLIC || commander.public, - machine_name : process.env.INSTANCE_NAME || commander.machineName, + secret_key : cst.SECRET_KEY || commander.secret, + public_key : cst.PUBLIC_KEY || commander.public, + machine_name : cst.MACHINE_NAME || commander.machineName, daemon_mode : process.env.PM2_RUNTIME_DEBUG || false });