fix: 收敛 WebProbe 物理内存与资源上限
This commit is contained in:
@@ -36,6 +36,7 @@ interface RemoteGcOptions {
|
||||
full: boolean;
|
||||
historyLimit: number;
|
||||
saveSnapshot: boolean;
|
||||
memoryPressureOnly: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_REMOTE_OPTIONS: RemoteGcOptions = {
|
||||
@@ -65,6 +66,7 @@ const DEFAULT_REMOTE_OPTIONS: RemoteGcOptions = {
|
||||
full: false,
|
||||
historyLimit: 12,
|
||||
saveSnapshot: true,
|
||||
memoryPressureOnly: false,
|
||||
};
|
||||
|
||||
const GC_CONFIG_RELATIVE_PATH = "config/unidesk-cli.yaml";
|
||||
@@ -124,6 +126,16 @@ export async function runRemoteGcCommand(config: UniDeskConfig, providerId: stri
|
||||
};
|
||||
}
|
||||
const options = parseRemoteGcOptions(args);
|
||||
if (options.memoryPressureOnly && subaction !== "plan" && subaction !== "run") {
|
||||
return {
|
||||
ok: false,
|
||||
error: "gc-remote-memory-pressure-only-action-invalid",
|
||||
action: subaction,
|
||||
supportedActions: ["plan", "run"],
|
||||
planCommand: `bun scripts/cli.ts gc remote ${providerId} plan --memory-pressure-only`,
|
||||
runCommand: `bun scripts/cli.ts gc remote ${providerId} run --confirm --memory-pressure-only`,
|
||||
};
|
||||
}
|
||||
if (subaction === "memory") return await runRemoteGc(config, providerId, "memory", options);
|
||||
if (subaction === "plan" || subaction === "dry-run") return await runRemoteGc(config, providerId, "plan", options);
|
||||
if (subaction === "snapshot" || subaction === "growth") return await runRemoteGc(config, providerId, "snapshot", options);
|
||||
@@ -137,8 +149,8 @@ export async function runRemoteGcCommand(config: UniDeskConfig, providerId: stri
|
||||
dryRun: true,
|
||||
mutation: false,
|
||||
requiredFlag: "--confirm",
|
||||
planCommand: `bun scripts/cli.ts gc remote ${providerId} plan`,
|
||||
runCommand: `bun scripts/cli.ts gc remote ${providerId} run --confirm`,
|
||||
planCommand: `bun scripts/cli.ts gc remote ${providerId} plan${options.memoryPressureOnly ? " --memory-pressure-only" : ""}`,
|
||||
runCommand: `bun scripts/cli.ts gc remote ${providerId} run --confirm${options.memoryPressureOnly ? " --memory-pressure-only" : ""}`,
|
||||
};
|
||||
}
|
||||
return await runRemoteGc(config, providerId, "run", options);
|
||||
@@ -239,6 +251,8 @@ function parseRemoteGcOptions(args: string[]): RemoteGcOptions {
|
||||
options.full = true;
|
||||
} else if (arg === "--no-save" || arg === "--no-snapshot-save") {
|
||||
options.saveSnapshot = false;
|
||||
} else if (arg === "--memory-pressure-only") {
|
||||
options.memoryPressureOnly = true;
|
||||
} else {
|
||||
throw new Error(`unknown gc remote option: ${arg}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user