mirror of
https://github.com/thedrewen/protojx-manager.git
synced 2026-03-21 01:48:54 +01:00
Merge branch 'main' of https://github.com/thedrewen/protojx-manager-non-official
This commit is contained in:
@@ -101,10 +101,12 @@ export class StatusService {
|
||||
|
||||
private async fetch(max = 1): Promise<Host[]> {
|
||||
|
||||
const hosts = this.hosts.filter((value, index) => index < max * 10 && index >= (max - 1) * 10);
|
||||
const max_ping = 3;
|
||||
|
||||
const hosts = this.hosts.filter((value, index) => index < max * max_ping && index >= (max - 1) * max_ping);
|
||||
async function fetchAlive(host: Host) {
|
||||
if(host.type === 'ping'){
|
||||
let res = await ping.promise.probe(host.host, {timeout: 3});
|
||||
let res = await ping.promise.probe(host.host, {timeout: 10});
|
||||
host.alive = res.alive;
|
||||
}else if(host.type === 'website'){
|
||||
try {
|
||||
@@ -121,13 +123,13 @@ export class StatusService {
|
||||
const updatedHosts = await Promise.all(fetchPromises);
|
||||
|
||||
updatedHosts.forEach((updatedHost, index) => {
|
||||
const originalIndex = (max - 1) * 10 + index;
|
||||
const originalIndex = (max - 1) * max_ping + index;
|
||||
if (originalIndex < this.hosts.length) {
|
||||
this.hosts[originalIndex] = updatedHost;
|
||||
}
|
||||
});
|
||||
|
||||
if(this.hosts.length > max * 10) {
|
||||
if(this.hosts.length > max * max_ping) {
|
||||
await this.fetch(max + 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user