fix(scheduled-task): enable worker by default and add WeChat preflight
Memind CI / Test, build, and release guards (push) Has been cancelled
Memind CI / Test, build, and release guards (push) Has been cancelled
Scheduled automations were saved but never executed because the worker required an explicit env flag. Follow H5_REMINDER_WORKER_ENABLED when unset, add WeChat preflight to write tasks deterministically, and surface worker warnings on create. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Scheduled task worker enablement.
|
||||
* Explicit H5_SCHEDULED_TASK_WORKER_ENABLED=1 always wins.
|
||||
* Explicit =0 always disables.
|
||||
* When unset, follow H5_REMINDER_WORKER_ENABLED so production schedule stacks
|
||||
* that already run reminder worker also execute scheduled automations.
|
||||
*/
|
||||
export function isScheduledTaskWorkerEnabled(env = process.env) {
|
||||
const explicit = String(env.H5_SCHEDULED_TASK_WORKER_ENABLED ?? '').trim();
|
||||
if (explicit === '1') return true;
|
||||
if (explicit === '0') return false;
|
||||
return env.H5_REMINDER_WORKER_ENABLED === '1';
|
||||
}
|
||||
|
||||
export function scheduledTaskWorkerDisabledMessage(env = process.env) {
|
||||
if (isScheduledTaskWorkerEnabled(env)) return null;
|
||||
return '任务已保存,但当前环境未开启定时自动执行 Worker;到点不会自动跑任务。请联系管理员开启 H5_SCHEDULED_TASK_WORKER_ENABLED=1,或与 H5_REMINDER_WORKER_ENABLED=1 一并启用。';
|
||||
}
|
||||
Reference in New Issue
Block a user