Skip to content

Commit

Permalink
Fix website down retry delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed Nov 27, 2023
1 parent 7e32c07 commit 53d4d62
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ const check = () => {
ping: 0
});
});

request.on('timeout', () => {
resolve({
status: 'offline',
statusCode: -1,
ping: 0
});
});
});
};

Expand Down Expand Up @@ -239,14 +247,15 @@ const retry = (result) => {
}
resolve();
});
}, config.RetryInterval);
}, config.RecheckTime);
});
};

// start checking loop. if status is not online, retry after some time
const start = () => {
check().then((result) => {
if (result.status !== 'online' && result.status !== 'techwork') {
console.log(`Website is down, retrying in ${config.RecheckTime / 1000} seconds...`);
retry(result).then(() => {
setTimeout(start, config.CheckInterval);
});
Expand Down

0 comments on commit 53d4d62

Please sign in to comment.