From eb0fa6cbcce1650d6e9545e46a1d3df03657c83c Mon Sep 17 00:00:00 2001 From: vitya Date: Fri, 28 Aug 2026 01:22:16 +0300 Subject: [PATCH] =?UTF-8?q?sched:=20alerts=20=D0=BF=D1=80=D0=BE=D0=B3?= =?UTF-8?q?=D1=80=D0=B0=D0=BC=D0=BC=D0=BD=D0=BE=20=D1=87=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=20SCHED=5FALERTS=5FWEBHOOK=5FURL=20(=D0=BE=D0=B1=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=20fileAlerts).=20=D0=9F=D0=BE=D0=BA=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=81=D1=80=D0=B0=D0=B1=D0=B0=D1=82=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20onRunFinal=20=D0=B2=20published=200.12.1=20?= =?UTF-8?q?=E2=80=94=20=D0=B4=D0=B8=D0=B0=D0=B3=D0=BD=D0=BE=D0=B7:=20?= =?UTF-8?q?=D0=BD=D1=83=D0=B6=D0=B5=D0=BD=20books-=D1=84=D0=BE=D1=80=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vds-kzntsv/sched-custom/custom-entry.mjs | 16 ++++++++++++++++ host-stacks/vds-kzntsv/sched.compose.yml | 2 ++ 2 files changed, 18 insertions(+) diff --git a/host-stacks/vds-kzntsv/sched-custom/custom-entry.mjs b/host-stacks/vds-kzntsv/sched-custom/custom-entry.mjs index 130be4d..9ae253e 100644 --- a/host-stacks/vds-kzntsv/sched-custom/custom-entry.mjs +++ b/host-stacks/vds-kzntsv/sched-custom/custom-entry.mjs @@ -32,9 +32,25 @@ const storage = await createMysqlStorage(pool); // self-migrates on open const dbName = dbNameFromUrl(MYSQL_URL); // --- daemon: engine only (we own the http server) --- +// Programmatic alerts (from env), NOT the tasks.json block: the published @schedjs/daemon 0.12.1 +// does not wire onRunFinal from the file alerts block reliably (books-vds uses a books-built +// daemon where it does). Passing `alerts` explicitly guarantees the onRunFinal hook is set. +const ALERT_WEBHOOK = process.env.SCHED_ALERTS_WEBHOOK_URL; +const ALERT_BASIC = process.env.SCHED_ALERTS_BASIC_AUTH; // base64 `user:pass`, optional const daemon = createDaemon({ storage, tasksPath: TASKS, + ...(ALERT_WEBHOOK + ? { alerts: { + on: ['failed'], + onMissed: true, + onSyncFailed: true, + webhook: { + url: ALERT_WEBHOOK, + ...(ALERT_BASIC ? { headers: { Authorization: `Basic ${ALERT_BASIC}` } } : {}), + }, + } } + : {}), // no `admin` here — createDaemon would bind its own /api-only server; we route ourselves }); await daemon.start(); diff --git a/host-stacks/vds-kzntsv/sched.compose.yml b/host-stacks/vds-kzntsv/sched.compose.yml index c35de45..046fb6e 100644 --- a/host-stacks/vds-kzntsv/sched.compose.yml +++ b/host-stacks/vds-kzntsv/sched.compose.yml @@ -20,6 +20,8 @@ services: SCHED_TASKS: /app/config/tasks.json MYSQL_URL: mysql://sched:${SCHED_DB_PASS}@mariadb:3306/sched?ssl={"rejectUnauthorized":false} SCHED_ADMIN_KEY: ${SCHED_ADMIN_KEY} + SCHED_ALERTS_WEBHOOK_URL: ${SCHED_ALERTS_WEBHOOK_URL} + SCHED_ALERTS_BASIC_AUTH: ${SCHED_ALERTS_BASIC_AUTH} volumes: - /opt/stacks/sched/tasks.json:/app/config/tasks.json:ro healthcheck: