From 8748c0e383475f5b479a9868edbd53bb869bf12e Mon Sep 17 00:00:00 2001 From: Claw Date: Fri, 6 Mar 2026 11:16:39 +0000 Subject: [PATCH] fix: send telegram on SIGTERM so partial cron runs still notify when jobs found --- job_searcher.mjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/job_searcher.mjs b/job_searcher.mjs index aa77084..3b0ff9a 100644 --- a/job_searcher.mjs +++ b/job_searcher.mjs @@ -33,6 +33,17 @@ async function main() { const platformsRun = []; const startedAt = Date.now(); + const settings = loadConfig(resolve(__dir, 'config/settings.json')); + + // Send notification even if SIGTERM kills the process mid-run + process.once('SIGTERM', async () => { + if (totalAdded > 0) { + const summary = formatSearchSummary(totalAdded, totalSeen - totalAdded, platformsRun.length ? platformsRun : ['LinkedIn']); + await sendTelegram(settings, summary + '\n_(partial run — timed out)_').catch(() => {}); + } + process.exit(0); + }); + const writeLastRun = (finished = false) => { const entry = { started_at: startedAt, @@ -63,7 +74,6 @@ async function main() { }); // Load config - const settings = loadConfig(resolve(__dir, 'config/settings.json')); const searchConfig = loadConfig(resolve(__dir, 'config/search_config.json')); // First run detection: if queue is empty, use first_run_days lookback