Fixing sync bug where deleted container would re-appear after deletion

This commit is contained in:
Jeff Morgan 2014-12-09 22:58:15 -08:00
parent 9e3c063fe9
commit d64e347850
2 changed files with 17 additions and 17 deletions

View File

@ -67,10 +67,10 @@ AppUtil.stop = function (appId) {
AppUtil.remove = function (appId) { AppUtil.remove = function (appId) {
var app = Apps.findOne(appId); var app = Apps.findOne(appId);
if (app.docker) { if (app.docker) {
Apps.remove({_id: appId});
Docker.removeContainer(app.docker.Id, function (err) { Docker.removeContainer(app.docker.Id, function (err) {
var appPath = path.join(Util.KITE_PATH, app.name); var appPath = path.join(Util.KITE_PATH, app.name);
Util.deleteFolder(appPath); Util.deleteFolder(appPath);
Apps.remove({_id: appId});
}); });
} else { } else {
Apps.remove({_id: appId}); Apps.remove({_id: appId});
@ -153,7 +153,7 @@ AppUtil.sync = function (callback) {
var diffApps = _.difference(guiIds, containerIds); var diffApps = _.difference(guiIds, containerIds);
_.each(diffApps, function (appContainerId) { _.each(diffApps, function (appContainerId) {
var app = Apps.findOne({'docker.Id': appContainerId}); var app = Apps.findOne({'docker.Id': appContainerId});
if (app) { if (app && app.status !== 'STARTING') {
AppUtil.remove(app._id); AppUtil.remove(app._id);
} }
}); });

View File

@ -221,24 +221,24 @@ updateBoot2DockerUtilization = function (callback) {
}); });
}; };
startUpdatingBoot2DockerUtilization = function () { startUpdatingBoot2DockerUtilization = function () {
updateBoot2DockerUtilization(function (err) { updateBoot2DockerUtilization(function (err) { if (err) {console.log(err);} });
if (err) {console.log(err);} Meteor.setTimeout(startUpdatingBoot2DockerUtilization, 2000);
Meteor.setTimeout(startUpdatingBoot2DockerUtilization, 2000);
});
}; };
startSyncingAppState = function () { startSyncingAppState = function () {
try { console.log('app');
ImageUtil.sync(function (err) { ImageUtil.sync(function (err) {
if (err) {throw err;} if (err) {
AppUtil.sync(function (err) { console.log(err);
if (err) {throw err;} }
Meteor.setTimeout(startSyncingAppState, 2000); AppUtil.sync(function (err) {
}); if (err) {
console.log(err);
}
}); });
} catch (err) { });
console.log(err); Meteor.setTimeout(startSyncingAppState, 2000);
Meteor.setTimeout(startSyncingAppState, 2000);
}
}; };