scripts/worker-health.ts
此代码来自构建时的仓库快照。修改源码后重新构建即可更新。
import 'dotenv/config';
import { heartbeatScope } from '../src/server/jobs/heartbeat';
import { queueHealth } from '../src/server/jobs/health';
async function main() {
// 独立短进程检查当前作用域的有效登记;同作用域至少一个进程可接工作才算健康。
const timeout = setTimeout(() => {
process.exit(1);
}, 4000);
try {
const health = await queueHealth(heartbeatScope());
process.exitCode = health.redis && health.worker ? 0 : 1;
} catch {
process.exitCode = 1;
} finally {
clearTimeout(timeout);
}
}
void main();