diff --git a/src/locker.js b/src/locker.js index e3b219b01..ac679714f 100644 --- a/src/locker.js +++ b/src/locker.js @@ -15,6 +15,7 @@ util.inherits(Locker, EventEmitter); // these are mutually exclusive operations Locker.prototype.OP_BOX_UPDATE = 'box_update'; +Locker.prototype.OP_PLATFORM_START = 'platform_start'; Locker.prototype.OP_FULL_BACKUP = 'full_backup'; Locker.prototype.OP_APPTASK = 'apptask'; Locker.prototype.OP_MIGRATE = 'migrate'; diff --git a/src/platform.js b/src/platform.js index 34deb89e6..4ba17ed1d 100644 --- a/src/platform.js +++ b/src/platform.js @@ -17,6 +17,7 @@ var apps = require('./apps.js'), fs = require('fs'), hat = require('hat'), infra = require('./infra_version.js'), + locker = require('./locker.js'), nginx = require('./nginx.js'), os = require('os'), paths = require('./paths.js'), @@ -63,6 +64,9 @@ function start(callback) { debug('Updating infrastructure from %s to %s', existingInfra.version, infra.version); + var error = locker.lock(locker.OP_PLATFORM_START); + if (error) return callback(error); + async.series([ stopContainers.bind(null, existingInfra), startAddons.bind(null, existingInfra), @@ -72,6 +76,8 @@ function start(callback) { ], function (error) { if (error) return callback(error); + locker.unlock(locker.OP_PLATFORM_START); + emitPlatformReady(); callback();