installer: retry fetching installer data 5 times
On some VPS providers, getting the userData is "flaky". Fixes #3
This commit is contained in:
+12
-6
@@ -58,18 +58,24 @@ function provision(callback) {
|
|||||||
return callback(null); // already provisioned
|
return callback(null); // already provisioned
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async.retry({ times: 5, interval: 30000 }, function (done) {
|
||||||
// try first digitalocean, then ec2
|
// try first digitalocean, then ec2
|
||||||
provisionDigitalOcean(function (error, userData) {
|
provisionDigitalOcean(function (error1, userData) {
|
||||||
if (!error) return installer.provision(userData, callback);
|
if (!error1) return done(null, userData);
|
||||||
|
|
||||||
provisionEC2(function (error, userData) {
|
provisionEC2(function (error2, userData) {
|
||||||
if (!error) return installer.provision(userData, callback);
|
if (!error2) return done(null, userData);
|
||||||
|
|
||||||
console.error('Unable to get meta data', error);
|
console.error('Unable to get meta data: ', error1.message + ' ' + error2.message);
|
||||||
|
|
||||||
callback(new Error('Error getting metadata'));
|
callback(new Error(error1.message + ' ' + error2.message));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}, function (error, userData) {
|
||||||
|
if (error) return callback(error);
|
||||||
|
|
||||||
|
installer.provision(userData, callback);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function provisionLocal(callback) {
|
function provisionLocal(callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user