diff --git a/lib/God.js b/lib/God.js index ac610c44..f41234dc 100644 --- a/lib/God.js +++ b/lib/God.js @@ -338,6 +338,8 @@ God.handleExit = function handleExit(clu, exit_code, kill_signal) { } if (!stopping && !overlimit) { + //make this property unenumerable + Object.defineProperty(proc.pm2_env, 'restart_task', {configurable: true, writable: true}); proc.pm2_env.restart_task = setTimeout(function() { proc.pm2_env.restart_time += 1; God.executeApp(proc.pm2_env); diff --git a/lib/God/ActionMethods.js b/lib/God/ActionMethods.js index ee71a07c..045942a6 100644 --- a/lib/God/ActionMethods.js +++ b/lib/God/ActionMethods.js @@ -242,15 +242,13 @@ module.exports = function(God) { if (!(id in God.clusters_db)) return cb(God.logAndGenerateError(id + ' : id unknown'), {}); - var proc = God.clusters_db[id]; - //clear time-out restart task - clearTimeout(proc.pm2_env.restart_task); + clearTimeout(God.clusters_db[id].pm2_env.restart_task); - if (proc.pm2_env.status == cst.STOPPED_STATUS) + if (God.clusters_db[id].pm2_env.status == cst.STOPPED_STATUS) return cb(null, God.getFormatedProcess(id)); // state == 'none' means that the process is not online yet - if (proc.state && proc.state === 'none') + if (God.clusters_db[id].state && God.clusters_db[id].state === 'none') return setTimeout(function() { God.stopProcessId(id, cb); }, 250); var proc = God.clusters_db[id];