diff --git a/.travis.yml b/.travis.yml index f6594515..60c67159 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: node_js node_js: - - "4" - - "6" - - "7" + - "0.12" + - "4" + - "6" + - "7" os: - linux before_install: diff --git a/constants.js b/constants.js index 678ebfea..2522b4cc 100644 --- a/constants.js +++ b/constants.js @@ -69,13 +69,13 @@ var csts = { TRACE_FLUSH_INTERVAL : process.env.PM2_DEBUG || process.env.NODE_ENV === 'local_test' ? 1000 : 60000, // Concurrent actions when doing start/restart/reload - CONCURRENT_ACTIONS : ((() => { + CONCURRENT_ACTIONS : (function() { var concurrent_actions = parseInt(process.env.PM2_CONCURRENT_ACTIONS) || 1; if (semver.satisfies(process.versions.node, '>= 4.0.0')) concurrent_actions = 2; debug('Using %d parallelism (CONCURRENT_ACTIONS)', concurrent_actions); return concurrent_actions; - }))(), + })(), DEBUG : process.env.PM2_DEBUG || false, WEB_IPADDR : process.env.PM2_API_IPADDR || '0.0.0.0', diff --git a/lib/API/Configuration.js b/lib/API/Configuration.js index 3add1ac1..01b4439a 100644 --- a/lib/API/Configuration.js +++ b/lib/API/Configuration.js @@ -9,26 +9,28 @@ var Configuration = require('../Configuration.js'); //@todo double check that imported methods works var InteractorDaemonizer = require('../Interactor/InteractorDaemonizer'); -module.exports = CLI => { +module.exports = function(CLI) { CLI.prototype.get = function(key, cb) { var that = this; if (!key || key == 'all') { - displayConf((err, data) => { + displayConf(function(err, data) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); }); return false; } - Configuration.get(key, (err, data) => { + Configuration.get(key, function(err, data) { if (err) { return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); } // pm2 conf module-name if (key.indexOf(':') === -1 && key.indexOf('.') === -1) { - displayConf(key, () => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); + displayConf(key, function() { + return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT) + }); return false; } // pm2 conf module-name:key @@ -53,7 +55,7 @@ module.exports = CLI => { var that = this; if (!key) { - interactiveConfigEdit(err => { + interactiveConfigEdit(function(err) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); @@ -68,17 +70,21 @@ module.exports = CLI => { */ if (key.indexOf('pm2:passwd') > -1) { value = Password.generate(value); - Configuration.set(key, value, err => { + Configuration.set(key, value, function(err) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); - InteractorDaemonizer.launchRPC(that._conf, err => { + InteractorDaemonizer.launchRPC(that._conf, function(err) { if (err) { - displayConf('pm2', () => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); + displayConf('pm2', function() { + return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT) + }); return false; } - InteractorDaemonizer.rpc.passwordSet(() => { - InteractorDaemonizer.disconnectRPC(() => { - displayConf('pm2', () => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); + InteractorDaemonizer.rpc.passwordSet(function() { + InteractorDaemonizer.disconnectRPC(function() { + displayConf('pm2', function() { + return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); + }); }); }); return false; @@ -90,7 +96,7 @@ module.exports = CLI => { /** * Set value */ - Configuration.set(key, value, err => { + Configuration.set(key, value, function(err) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); @@ -109,22 +115,26 @@ module.exports = CLI => { process.env.PM2_PROGRAMMATIC = 'true'; that.restart(app_name, { updateEnv : true - }, (err, data) => { + }, function(err, data) { process.env.PM2_PROGRAMMATIC = 'false'; if (!err) Common.printOut(cst.PREFIX_MSG + 'Module %s restarted', app_name); - displayConf(app_name, () => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); + displayConf(app_name, function() { + return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); + }); }); return false; } - displayConf(null, () => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); + displayConf(null, function() { + return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); + }); }); }; CLI.prototype.multiset = function(serial, cb) { var that = this; - Configuration.multiset(serial, (err, data) => { + Configuration.multiset(serial, function(err, data) { if (err) return cb ? cb({success:false, err:err}) : that.exitCli(cst.ERROR_EXIT); @@ -144,28 +154,31 @@ module.exports = CLI => { process.env.PM2_PROGRAMMATIC = 'true'; that.restart(app_name, { updateEnv : true - }, (err, data) => { + }, function(err, data) { process.env.PM2_PROGRAMMATIC = 'false'; if (!err) Common.printOut(cst.PREFIX_MSG + 'Module %s restarted', app_name); - displayConf(app_name, () => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); + displayConf(app_name, function() { + return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT) + }); }); return false; } - displayConf(app_name, () => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); - + displayConf(app_name, function() { + return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT) + }); }); }; CLI.prototype.unset = function(key, cb) { var that = this; - Configuration.unset(key, err => { + Configuration.unset(key, function(err) { if (err) { return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); } - displayConf(() => cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT)); + displayConf(function() { cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT) }); }); }; @@ -179,7 +192,7 @@ module.exports = CLI => { // If key + value = set if (key && value) { - that.set(key, value, err => { + that.set(key, value, function(err) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); @@ -187,14 +200,14 @@ module.exports = CLI => { } // If only key = get else if (key) { - that.get(key, (err, data) => { + that.get(key, function(err, data) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); }); } else { - interactiveConfigEdit(err => { + interactiveConfigEdit(function(err) { if (err) return cb ? cb(Common.retErr(err)) : that.exitCli(cst.ERROR_EXIT); return cb ? cb(null, {success:true}) : that.exitCli(cst.SUCCESS_EXIT); @@ -205,7 +218,7 @@ module.exports = CLI => { }; function interactiveConfigEdit(cb) { - UX.openEditor(cst.PM2_MODULE_CONF_FILE, (err, data) => { + UX.openEditor(cst.PM2_MODULE_CONF_FILE, function(err, data) { Common.printOut(chalk.bold('Module configuration (%s) edited.'), cst.PM2_MODULE_CONF_FILE); Common.printOut(chalk.bold('To take changes into account, please restart module related.'), cst.PM2_MODULE_CONF_FILE); if (err) @@ -224,7 +237,7 @@ function displayConf(target_app, cb) { target_app = null; } - Configuration.getAll((err, data) => { + Configuration.getAll(function(err, data) { UX.dispKeys(data, target_app); return cb(); }); diff --git a/package.json b/package.json index a5ebf8e6..6831b9fc 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "preferGlobal": true, "version": "3.0.0", "engines": { - "node": ">=4" + "node": ">=0.12" }, "directories": { "bin": "./bin",