-
-
Save arcseldon/c97ee0c177cea276193e81db2e25864a to your computer and use it in GitHub Desktop.
This file contains 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
import _ from 'lodash'; | |
import fetch from 'node-fetch'; | |
import delay from 'delay'; | |
export async function pingServers(servers) { | |
let failedServers = {}; | |
for (const url of servers) { | |
let failures = 0; | |
for (const i of _.range(3)) { | |
const response = await fetch(url); | |
if (!response.ok) failures++; | |
await delay(10000); | |
} | |
if (failures > 0) failedServers[url] = failures; | |
} | |
return failedServers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment