Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import _ from 'lodash';
- import fetch from 'node-fetch';
- import delay from 'delay';
- import co from 'co';
- export const pingServers = (servers) => co(function*() {
- let failedServers = {};
- for (const url of servers) {
- let failures = 0;
- for (const i of _.range(3)) {
- const response = yield fetch(url);
- if (!response.ok) failures++;
- yield delay(10000);
- }
- if (failures > 0) failedServers[url] = failures;
- }
- return failedServers;
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement