diff --git a/back/config/util.ts b/back/config/util.ts index 47b7b183..e4a7ce69 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -398,8 +398,8 @@ export function psTree(pid: number): Promise { } export function isPidRunning(pid: number): boolean { - // Validate PID is a positive integer - if (!pid || pid <= 0 || !Number.isInteger(pid)) { + // Validate PID: must be a positive integer + if (pid == null || pid <= 0 || !Number.isInteger(pid)) { return false; } diff --git a/back/loaders/initData.ts b/back/loaders/initData.ts index 8fbe3b08..c9d87c74 100644 --- a/back/loaders/initData.ts +++ b/back/loaders/initData.ts @@ -143,7 +143,9 @@ export default async () => { continue; } // 收集需要重置的任务 ID - idsToReset.push(cron.id!); + if (cron.id) { + idsToReset.push(cron.id); + } } // 批量更新所有需要重置的任务