Retry activation in case the we still get redirects
This commit is contained in:
parent
e27211b73e
commit
6189e7a6dc
18
cloudron.js
18
cloudron.js
@ -82,8 +82,22 @@ Cloudron.prototype.activate = function (user) {
|
||||
var setupToken = this._box.setupToken;
|
||||
|
||||
////////// activation
|
||||
var res = request.post(this._origin + '/api/v1/cloudron/activate').query({ setupToken: setupToken }).send(user).end();
|
||||
common.verifyResponse2xx(res, 'Could not activate the box'); // 409 - already activated
|
||||
var res;
|
||||
for (var i = 0; i < 40; ++i) {
|
||||
sleep(5);
|
||||
|
||||
res = request.post(this._origin + '/api/v1/cloudron/activate').query({ setupToken: setupToken }).send(user).end();
|
||||
|
||||
if (res.statusCode === 201) break;
|
||||
if (res.statusCode === 307) continue;
|
||||
if (res.statusCode === 409) {
|
||||
debug('Response error statusCode:%s error:%s body:%j', res.statusCode, res.error, res.body);
|
||||
throw new Error('Cloudron already activated! This should not happen');
|
||||
}
|
||||
}
|
||||
|
||||
// final verification will fail if retries do not succeed
|
||||
common.verifyResponse2xx(res, 'Could not activate the box');
|
||||
|
||||
res = request.get(this._origin + '/api/v1/cloudron/status').end();
|
||||
common.verifyResponse2xx(res, 'Could not get Cloudron status');
|
||||
|
Loading…
Reference in New Issue
Block a user