Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #516 from Financial-Times/support-https
Browse files Browse the repository at this point in the history
Support https; Nicer errors; Moar emojis; Reject on any error other 'FetchError: network timeout'
  • Loading branch information
Adam Braimbridge authored Aug 21, 2018
2 parents eb84f64 + 6e781de commit 8aed989
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
18 changes: 13 additions & 5 deletions lib/wait-for-ok.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ module.exports = function (url) {
let timeout;
let checker;
function checkGtg () {
console.log(`polling: ${url}`); // eslint-disable-line no-console
console.log(`polling: ${url}`); // eslint-disable-line no-console
fetch(url, { timeout: 2000, follow: 0 })
.then(function (response) {
if (response.ok) {
console.log(`poll ${url} ok`); // eslint-disable-line no-console
console.log(` ${url} ok!`); // eslint-disable-line no-console
clearTimeout(timeout);
clearInterval(checker);
resolve();
} else {
console.log(`poll ${url} not ok`); // eslint-disable-line no-console
console.log(`❌ ${url} not ok`); // eslint-disable-line no-console
}
})
.catch(error => {
if (error.type && error.type === 'request-timeout') {
console.log(`👋 Hey, ${url} doesn't seem to be responding yet, so there's that. You're amazing, by the way. I don't say that often enough. But you really are.`); // eslint-disable-line no-console
}
else {
reject(`😿 ${url} Error: ${error}`);
clearInterval(checker);
}
});
}
checker = setInterval(checkGtg, 3000);
timeout = setTimeout(function () {
console.log('2 minutes passed, bailing'); // eslint-disable-line no-console
reject(`${url} not responding with an ok response within 2 minutes`);
reject(`😢 ${url} did not respond with an ok response within two minutes.`);
clearInterval(checker);
}, 2*60*1000);
});
Expand Down
2 changes: 1 addition & 1 deletion tasks/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If this app has no web process use the --skip-gtg option`);

smokeTest.addCheck('cacheHeaders', require('../lib/verify-cache-headers'));

return waitForOk(`http://${name}.herokuapp.com/__gtg`)
return waitForOk(`https://${name}.herokuapp.com/__gtg`)
.then(() => smokeTest.run())
.catch(err => {
console.log('/**************** heroku app logs start ****************/'); // eslint-disable-line no-console
Expand Down
1 change: 0 additions & 1 deletion tasks/float.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function task (opts) {
log.art.canoe();
log.success('IT FLOATS!');
}).catch(function (err) {
log.error('Man overboard', err);
if (opts.destroy) {
return destroy({ app: testAppName, verbose: true })
.then(function () {
Expand Down

0 comments on commit 8aed989

Please sign in to comment.