Commit b134d8b5 by Lin Wang

feat: exit the process

parent 106e9094
docker build -t reg.i.strikingly.com/falcon:v0.6.4 . docker build -t reg.i.strikingly.com/falcon:v0.6.6 .
docker push reg.i.strikingly.com/falcon:v0.6.4 docker push reg.i.strikingly.com/falcon:v0.6.6
\ No newline at end of file \ No newline at end of file
...@@ -12,7 +12,7 @@ async function main() { ...@@ -12,7 +12,7 @@ async function main() {
const shouldRun = await redis.get("falcon:should_run_tasks"); const shouldRun = await redis.get("falcon:should_run_tasks");
if (shouldRun === "true") { if (true) {
task_trigger = "should_run_tasks"; task_trigger = "should_run_tasks";
await redis.del("falcon:should_run_tasks"); await redis.del("falcon:should_run_tasks");
} else if (isMonday11AM()) { } else if (isMonday11AM()) {
...@@ -38,21 +38,25 @@ async function main() { ...@@ -38,21 +38,25 @@ async function main() {
// 运行 bun run detect // 运行 bun run detect
console.log(`[${task_trigger}] 开始执行 detect`); console.log(`[${task_trigger}] 开始执行 detect`);
await spawn({ const detectProcess = spawn({
cmd: ["bun", "run", "detect"], cmd: ["bun", "run", "detect"],
env, env,
stdout: "inherit", stdout: "inherit",
stderr: "inherit" stderr: "inherit"
}); });
await detectProcess.exited;
console.log(`[${task_trigger}] detect 执行完成`);
// 运行 bun run task:gsheet // 运行 bun run task:gsheet
console.log(`[${task_trigger}] 开始执行 task:gsheet`); console.log(`[${task_trigger}] 开始执行 task:gsheet`);
await spawn({ const gsheetProcess = spawn({
cmd: ["bun", "run", "task:gsheet"], cmd: ["bun", "run", "task:gsheet"],
env, env,
stdout: "inherit", stdout: "inherit",
stderr: "inherit" stderr: "inherit"
}); });
await gsheetProcess.exited;
console.log(`[${task_trigger}] task:gsheet 执行完成`);
// 延迟执行 task:gsheet:ai 避免 Google Sheet 限流 // 延迟执行 task:gsheet:ai 避免 Google Sheet 限流
const delayMs = parseInt(process.env.GSHEET_AI_DELAY_MS ?? "60000", 10); const delayMs = parseInt(process.env.GSHEET_AI_DELAY_MS ?? "60000", 10);
...@@ -61,21 +65,25 @@ async function main() { ...@@ -61,21 +65,25 @@ async function main() {
// 运行 bun run task:gsheet:ai // 运行 bun run task:gsheet:ai
console.log(`[${task_trigger}] 开始执行 task:gsheet:ai`); console.log(`[${task_trigger}] 开始执行 task:gsheet:ai`);
await spawn({ const gsheetAiProcess = spawn({
cmd: ["bun", "run", "task:gsheet:ai"], cmd: ["bun", "run", "task:gsheet:ai"],
env, env,
stdout: "inherit", stdout: "inherit",
stderr: "inherit" stderr: "inherit"
}); });
await gsheetAiProcess.exited;
console.log(`[${task_trigger}] task:gsheet:ai 执行完成`);
// 运行 bun run notify-slack // 运行 bun run notify-slack
console.log(`[${task_trigger}] 开始执行 notify-slack`); console.log(`[${task_trigger}] 开始执行 notify-slack`);
await spawn({ const notifySlackProcess = spawn({
cmd: ["bun", "run", "notify-slack"], cmd: ["bun", "run", "notify-slack"],
env, env,
stdout: "inherit", stdout: "inherit",
stderr: "inherit" stderr: "inherit"
}); });
await notifySlackProcess.exited;
console.log(`[${task_trigger}] notify-slack 执行完成`);
if (task_trigger === "should_run_tasks") { if (task_trigger === "should_run_tasks") {
console.log(`[${task_trigger}] should_run_tasks 执行完毕,已清理 redis key。`); console.log(`[${task_trigger}] should_run_tasks 执行完毕,已清理 redis key。`);
...@@ -86,6 +94,9 @@ async function main() { ...@@ -86,6 +94,9 @@ async function main() {
} }
await redis.quit(); await redis.quit();
console.log(`[${task_trigger}] 任务执行完毕,退出。`);
process.exit(0);
} }
function isMonday11AM() { function isMonday11AM() {
......
...@@ -59,8 +59,6 @@ async function main() { ...@@ -59,8 +59,6 @@ async function main() {
issue: 'Inconsistencies are detected in i18n master section template', issue: 'Inconsistencies are detected in i18n master section template',
details: `Google Sheet Links:\n- Non-AI selectors: ${nonAiUrl}\n- AI selectors: ${aiUrl}` details: `Google Sheet Links:\n- Non-AI selectors: ${nonAiUrl}\n- AI selectors: ${aiUrl}`
}); });
process.exit(0);
} }
main().catch(err => { main().catch(err => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment