From 1ff7fd3d49ccaf3f65540774426b62fdc811e4f1 Mon Sep 17 00:00:00 2001 From: vince Date: Tue, 21 Aug 2018 10:49:54 +0200 Subject: [PATCH 1/2] fix: #3786 fix issue when triggering an action that does not exist --- lib/God/ActionMethods.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/God/ActionMethods.js b/lib/God/ActionMethods.js index c9272f645..0df19e03a 100644 --- a/lib/God/ActionMethods.js +++ b/lib/God/ActionMethods.js @@ -801,6 +801,22 @@ module.exports = function(God) { var proc_env = God.clusters_db[id].pm2_env; + var action_exist = false; + proc_env.axm_actions.forEach(function(action) { + console.log(action, cmd) + if (action.action_name === cmd.msg) { + action_exist = true; + } + }); + + // if action doesn't exist for this app + // try with the next one + if (action_exist === false) { + arr.shift(); + return ex(arr); + } + + if ((p.basename(proc_env.pm_exec_path) == name || proc_env.name == name) && (proc_env.status == cst.ONLINE_STATUS || From 6cbca8bccc0126f1557bf8326c81facc62100704 Mon Sep 17 00:00:00 2001 From: vince Date: Tue, 21 Aug 2018 11:51:16 +0200 Subject: [PATCH 2/2] refactor: #3786 clean code --- lib/God/ActionMethods.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/God/ActionMethods.js b/lib/God/ActionMethods.js index 0df19e03a..09a0c7faf 100644 --- a/lib/God/ActionMethods.js +++ b/lib/God/ActionMethods.js @@ -801,17 +801,11 @@ module.exports = function(God) { var proc_env = God.clusters_db[id].pm2_env; - var action_exist = false; - proc_env.axm_actions.forEach(function(action) { - console.log(action, cmd) - if (action.action_name === cmd.msg) { - action_exist = true; - } - }); + const isActionAvailable = proc_env.axm_actions.find(action => action.action_name === cmd.msg) !== undefined // if action doesn't exist for this app // try with the next one - if (action_exist === false) { + if (isActionAvailable === false) { arr.shift(); return ex(arr); }