mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-28 01:10:54 +01:00
fix: improve ping performance (#1020)
This commit is contained in:
@@ -15,18 +15,20 @@ export const pingJob = createCronJob("ping", EVERY_MINUTE, {
|
||||
}).withCallback(async () => {
|
||||
const urls = await pingUrlChannel.getAllAsync();
|
||||
|
||||
for (const url of new Set(urls)) {
|
||||
const pingResult = await sendPingRequestAsync(url);
|
||||
|
||||
if ("statusCode" in pingResult) {
|
||||
logger.debug(`executed ping for url ${url} with status code ${pingResult.statusCode}`);
|
||||
} else {
|
||||
logger.error(`Executing ping for url ${url} failed with error: ${pingResult.error}`);
|
||||
}
|
||||
|
||||
await pingChannel.publishAsync({
|
||||
url,
|
||||
...pingResult,
|
||||
});
|
||||
}
|
||||
await Promise.allSettled([...new Set(urls)].map(pingAsync));
|
||||
});
|
||||
|
||||
const pingAsync = async (url: string) => {
|
||||
const pingResult = await sendPingRequestAsync(url);
|
||||
|
||||
if ("statusCode" in pingResult) {
|
||||
logger.debug(`executed ping for url ${url} with status code ${pingResult.statusCode}`);
|
||||
} else {
|
||||
logger.error(`Executing ping for url ${url} failed with error: ${pingResult.error}`);
|
||||
}
|
||||
|
||||
await pingChannel.publishAsync({
|
||||
url,
|
||||
...pingResult,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user