Skip to content

Commit

Permalink
Fixed: multiple calls to vizion.parse() for the same process
Browse files Browse the repository at this point in the history
  • Loading branch information
jshkurti committed Jan 9, 2015
1 parent 202cea8 commit 0e798b1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/God.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ God.executeApp = function executeApp(env, cb) {
env_copy['axm_options'] = {};
env_copy['axm_dynamic'] = {};

if (!env_copy.created_at) env_copy['created_at'] = Date.now();
if (!env_copy.created_at)
env_copy['created_at'] = Date.now();

/**
* Enter here when it's the first time that the process is created
Expand All @@ -148,10 +149,11 @@ God.executeApp = function executeApp(env, cb) {
* 4 - If watch option is set, look for changes
*/
if (env_copy['pm_id'] === undefined || startingInside) {
env_copy['vizion_running'] = false;
env_copy['pm_id'] = God.getNewId();
env_copy['restart_time'] = 0;
env_copy['unstable_restarts'] = 0;
env_copy['started_inside'] = startingInside;
env_copy['started_inside'] = startingInside;

env_copy['command'] = {
locked : false,
Expand Down Expand Up @@ -409,9 +411,18 @@ God.finalizeProcedure = function finalizeProcedure(proc) {
var current_path = path.dirname(proc.pm2_env.pm_exec_path);
var proc_id = proc.pm2_env.pm_id;

if (proc.pm2_env.vizion_running === true)
{
console.log('Vizion is already running for proc id: %d, skipping this round', proc_id);
return God.notify('online', proc);
}

proc.pm2_env.vizion_running = true;
vizion.analyze({folder : current_path}, function recur_path(err, meta){
var proc = God.clusters_db[proc_id];

proc.pm2_env.vizion_running = false;

if (!proc ||
proc.pm2_env.status == cst.STOPPED_STATUS ||
proc.pm2_env.status == cst.STOPPING_STATUS) {
Expand All @@ -429,6 +440,7 @@ God.finalizeProcedure = function finalizeProcedure(proc) {
}
else {
current_path = path.dirname(current_path);
proc.pm2_env.vizion_running = true;
vizion.analyze({folder : current_path}, recur_path);
}
return false;
Expand Down
10 changes: 9 additions & 1 deletion lib/Worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ module.exports = function(God) {
proc.pm2_env.versioning.repo_path))
return cb();

if (proc.pm2_env.vizion_running === true)
{
console.log('Vizion is already running for proc id: %d, skipping this round', proc_id);
return cb();
}

proc.pm2_env.vizion_running = true;
vizion.analyze({
folder: proc.pm2_env.versioning.repo_path
},
Expand All @@ -74,6 +81,7 @@ module.exports = function(God) {
return cb();

proc = _getProcessById(proc_key.pm2_env.pm_id);
proc.pm2_env.vizion_running = false;

if (!(proc &&
proc.pm2_env &&
Expand Down Expand Up @@ -116,7 +124,7 @@ module.exports = function(God) {
});
}, function(err) {
God.Worker.is_running = false;
debug('[PM2][WORKER] My job here is done, next job in %d seconds', parseInt(cst.WORKER_INTERVAL));
debug('[PM2][WORKER] My job here is done, next job in %d seconds', parseInt(cst.WORKER_INTERVAL / 1000));
});
});
};
Expand Down

0 comments on commit 0e798b1

Please sign in to comment.