Created
September 18, 2017 23:49
-
-
Save codemilli/ee333027da984746269211c7ae2421ef to your computer and use it in GitHub Desktop.
check cloudfront invalidation done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i = 0; | |
var iteration = function () { | |
cloudfront.getInvalidation({ | |
DistributionId: dist, | |
Id: invalidationId | |
}, function (err, res) { | |
if (err) {return callback(err);} | |
if (res.Invalidation.Status === "Completed") { | |
return callback(); | |
} else { | |
var nextTry = Math.min(60000, 1000 * Math.pow(2, i++)); | |
log('Invalidation not done yet, next try in ' + nextTry + 'ms.'); | |
setTimeout(function () { | |
iteration(); | |
}, nextTry); | |
} | |
}); | |
}; | |
iteration(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment