Skip to content

Commit

Permalink
feat: 多线程文件更新巡检
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed Sep 15, 2024
1 parent ff2c430 commit 42c15af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,16 @@ export class Server {
console.log(`...file list was successfully updated. Found ${this.files.length} files`);
this.isUpdating = false;
if (checkClusters) {
for (const cluster of this.clusters.filter(c => c.isOnline)) {
const wardenPromises = this.clusters.filter(c => c.isOnline).map(async cluster => {
const message = await Utilities.checkSpecfiedFiles(Utilities.findDifferences(oldFiles, this.files, true), cluster); // 只查找新增的文件,不然删文件会把全部节点踢了
if (message) {
cluster.downReason = message;
cluster.isOnline = false;
this.db.update(cluster);
console.log(`Cluster ${cluster.clusterId} is down because of ${message}`);
}
}
});
await Promise.all(wardenPromises);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class Utilities {
}

public static async checkSpecfiedFiles(files: File[], cluster: ClusterEntity, attempt: number = -3): Promise<string | null> {
let result: string | null = "Error: This value should never be returned. if you see this message, please contact to the administrator.";
let result: string | null = "Error: This value should never be returned. if you see this message, please contact the developer.";

try {
const urls = files.map(f => Utilities.getUrl(f, cluster));
Expand Down

0 comments on commit 42c15af

Please sign in to comment.