Loop until box receives an update

This commit is contained in:
Girish Ramakrishnan 2015-07-16 15:05:06 -07:00
parent 41fc20b1a5
commit 6b7f9e5b9a

View File

@ -160,10 +160,17 @@ Cloudron.prototype.uninstallApp = function (appId) {
} }
Cloudron.prototype.update = function (toVersion) { Cloudron.prototype.update = function (toVersion) {
var res = request.post(this._origin + '/api/v1/cloudron/update').query({ access_token: this._credentials.accessToken }).send({ password: this._credentials.password }).end(); process.stdout.write('Trying to update');
verifyResponse(res, 'Could not update'); while (true) {
console.log('Update started'.green); sleep(10);
process.stdout.write('.');
var res = request.post(this._origin + '/api/v1/cloudron/update').query({ access_token: this._credentials.accessToken }).send({ password: this._credentials.password }).end();
if (res.statusCode === 422) continue; // box has not seen the update yet
verifyResponse(res, 'Could not update');
break;
}
console.log('Update started'.green);
process.stdout.write('Waiting for update.'); process.stdout.write('Waiting for update.');
for (var i = 0; i < 40; i++) { for (var i = 0; i < 40; i++) {
sleep(10); sleep(10);