Add a weekly digest and report which version of the agent each server runs
- Weekly digest through the notification channels: alerts now, a week of uptime, what happened, disks heading for full, expiring secrets and domains, updates waiting, planned maintenance. Off until switched on in Settings -> Notifications; Preview and Send it now there. Setting key 'digest'. - Agents say their version in every report (Linux and Windows scripts are version 2); the server compares it with the scripts it serves and marks agents that are behind on the Servers, server and Updates pages. servers.agent_version, migration 0026. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3da5c639b1
commit
aa94d84f6c
28 files changed
+3179
-19
No files matched your search
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Which version of the agent each server runs, and which version this Homelab Manager would give a new install. An agent is a copy of
|
||||
* a script that was served at install time, so after the app is updated the agents out on the servers can be behind. Each script carries
|
||||
* its version as a number (`AGENT_VERSION=2` / `$script:AgentVersion = 2`), says it in every report, and the "latest" is read from the very
|
||||
* scripts this app serves — so the two can never disagree about what "current" means.
|
||||
*
|
||||
* 1 — before the number was reported (so an agent that says nothing is version 1)
|
||||
* 2 — reports pending updates, and its own version
|
||||
*/
|
||||
import { readFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export type AgentOs = "linux" | "windows";
|
||||
export interface LatestAgentVersions {
|
||||
linux: number | null;
|
||||
windows: number | null;
|
||||
}
|
||||
|
||||
// server/src/services → the repository's agent folder (the same place the app serves /agent from; in the image it sits beside server/dist).
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
export const AGENT_DIR = join(here, "..", "..", "..", "agent");
|
||||
|
||||
const FILES: Record<AgentOs, string> = { linux: join("linux", "report-tasks.sh"), windows: join("windows", "report-tasks.ps1") };
|
||||
const PATTERNS: Record<AgentOs, RegExp> = {
|
||||
linux: /^AGENT_VERSION=(\d+)\s*$/m,
|
||||
windows: /^\$script:AgentVersion\s*=\s*(\d+)\s*$/m,
|
||||
};
|
||||
|
||||
/** The version a script says it is, or null if it doesn't say. */
|
||||
export function parseAgentVersion(text: string, os: AgentOs): number | null {
|
||||
const m = PATTERNS[os].exec(text.replace(/\r\n/g, "\n"));
|
||||
return m ? Number(m[1]) : null;
|
||||
}
|
||||
|
||||
let cached: LatestAgentVersions | null = null;
|
||||
|
||||
/** What the scripts served from here say. Read once (they don't change while the app runs); null for one that can't be read. */
|
||||
export function latestAgentVersions(dir: string = AGENT_DIR): LatestAgentVersions {
|
||||
if (cached && dir === AGENT_DIR) return cached;
|
||||
const read = (os: AgentOs): number | null => {
|
||||
try {
|
||||
return parseAgentVersion(readFileSync(join(dir, FILES[os]), "utf8"), os);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const result = { linux: read("linux"), windows: read("windows") };
|
||||
if (dir === AGENT_DIR) cached = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a server's agent is behind. Only a server that reports through an agent can be: one that never has (a Proxmox guest tracked
|
||||
* through its host, say) has none to update. An agent that reports no version is version 1.
|
||||
*/
|
||||
export function isAgentOutdated(row: { osType: string; lastSeenAt: string | null; agentVersion: number | null }, latest: LatestAgentVersions): boolean {
|
||||
if (!row.lastSeenAt) return false;
|
||||
const newest = row.osType === "windows" ? latest.windows : row.osType === "linux" ? latest.linux : null;
|
||||
if (newest === null) return false;
|
||||
return (row.agentVersion ?? 1) < newest;
|
||||
}
|
||||
@@ -104,6 +104,22 @@ async function isQuietHoursActive(): Promise<boolean> {
|
||||
return startMin < endMin ? nowMin >= startMin && nowMin < endMin : nowMin >= startMin || nowMin < endMin;
|
||||
}
|
||||
|
||||
/** Sends at once through every channel that is switched on, whatever the time — for something a person just asked for. */
|
||||
export async function notifyNow(title: string, message: string): Promise<void> {
|
||||
await sendToChannels(title, message);
|
||||
}
|
||||
|
||||
/** How many channels are switched on and filled in enough to send, so a "send it now" can say when there is nowhere to send to. */
|
||||
export async function enabledChannelCount(): Promise<number> {
|
||||
const { gotify, ntfy, smtp, webhook } = await getSettings();
|
||||
return [
|
||||
gotify.enabled && gotify.url && gotify.token,
|
||||
ntfy.enabled && ntfy.url && ntfy.topic,
|
||||
smtp.enabled && smtp.host && smtp.to && smtp.from,
|
||||
webhook.enabled && webhook.url,
|
||||
].filter(Boolean).length;
|
||||
}
|
||||
|
||||
export async function notify(title: string, message: string): Promise<void> {
|
||||
if (await isQuietHoursActive()) {
|
||||
await enqueueNotification(title, message);
|
||||
|
||||
@@ -99,6 +99,15 @@ export interface HealthCheckSettings {
|
||||
diskForecastDays: number;
|
||||
}
|
||||
|
||||
/** The weekly digest: one message a week through the notification channels. Off until an admin switches it on under Settings → Notifications. */
|
||||
export interface DigestSettings {
|
||||
enabled: boolean;
|
||||
/** 0 = Sunday … 6 = Saturday, in notifications.timezone. */
|
||||
day: number;
|
||||
/** "HH:MM", in notifications.timezone. */
|
||||
time: string;
|
||||
}
|
||||
|
||||
export interface ConsistencySettings {
|
||||
/** CIDR ranges and single addresses the consistency report ignores entirely — e.g. Docker networks that repeat on many hosts. */
|
||||
excludedRanges: string[];
|
||||
@@ -150,6 +159,7 @@ export interface AppSettings {
|
||||
logRetention: LogRetentionSettings;
|
||||
quietHours: QuietHoursSettings;
|
||||
healthChecks: HealthCheckSettings;
|
||||
digest: DigestSettings;
|
||||
consistency: ConsistencySettings;
|
||||
nameGenerator: NameGeneratorSettings;
|
||||
alertTickets: AlertTicketSettings;
|
||||
@@ -182,6 +192,7 @@ const DEFAULTS: AppSettings = {
|
||||
display: { dateFormat: "ymd", timeFormat: "24h", pageSize: 20 },
|
||||
logRetention: { enabled: false, retentionDays: 90, intervalHours: 24 },
|
||||
quietHours: { enabled: false, start: "22:00", end: "07:00" },
|
||||
digest: { enabled: false, day: 1, time: "08:00" },
|
||||
healthChecks: { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14 },
|
||||
// Docker's default bridge (172.17.0.0/16) and the pool it hands custom networks from (172.18–31) live here, and every
|
||||
// Docker host repeats them. Shown on the Consistency page, where it can be removed if 172.16/12 is used as a real LAN.
|
||||
|
||||
@@ -29,6 +29,8 @@ export interface AgentReport {
|
||||
hostname?: string;
|
||||
/** What the agent says it runs on. Only "linux" and "windows" are recorded; anything else is ignored. */
|
||||
osType?: string;
|
||||
/** Which version of the agent script is running. Absent from an agent that predates the number. */
|
||||
agentVersion?: number;
|
||||
system?: IncomingSystemInfo | null;
|
||||
tasks: IncomingTask[];
|
||||
}
|
||||
@@ -109,6 +111,7 @@ export async function syncServerTasks(serverId: number, report: AgentReport) {
|
||||
// Only stored when the agent reported it, so an agent that predates this (or couldn't tell this time) doesn't wipe what it said before.
|
||||
...(system?.updates && before ? nextUpdateState(before, system.updates, now) : {}),
|
||||
...(report.hostname ? { hostname: report.hostname } : {}),
|
||||
...(report.agentVersion !== undefined ? { agentVersion: report.agentVersion } : {}),
|
||||
// An agent knows what it runs on better than whoever registered the server did.
|
||||
...(report.osType === "linux" || report.osType === "windows" ? { osType: report.osType } : {}),
|
||||
...(system?.ip_addresses ? { ipAddresses: JSON.stringify(system.ip_addresses) } : {}),
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/**
|
||||
* The weekly digest: one message, sent through the notification channels, that says how the week went and what is coming — alerts now,
|
||||
* what was down and for how long, what happened, disks heading for full, things about to expire, updates waiting, planned maintenance.
|
||||
* Everything in it is already known to the app (the alerts, the uptime record, the audit log, the agents' reports); this only gathers it
|
||||
* into a few lines per topic and leaves out any topic with nothing to say. Plain text, so it reads in a phone notification and an email alike.
|
||||
*/
|
||||
import { db } from "../db/client.js";
|
||||
import { integrations, secrets, servers } from "../db/schema.js";
|
||||
import { env } from "../env.js";
|
||||
import { getAlerts } from "./alerts.js";
|
||||
import { getChangesSince } from "./changesSince.js";
|
||||
import { collectDomainAlerts } from "./domainMonitor.js";
|
||||
import { describeTarget, listUpcomingWindows } from "./maintenance.js";
|
||||
import { notify, notifyNow } from "./notify.js";
|
||||
import { parsePendingUpdates } from "./pendingUpdates.js";
|
||||
import { computeSecretStatus } from "./secretStatus.js";
|
||||
import { disksFillingSoon, getServerMetrics } from "./serverMetrics.js";
|
||||
import { getSettings } from "./settingsStore.js";
|
||||
import { getUptime } from "./uptimeHistory.js";
|
||||
|
||||
export const DIGEST_DAYS = 7;
|
||||
const DAY_MS = 24 * 3600_000;
|
||||
const MAX_LINES = 8;
|
||||
|
||||
export interface Digest {
|
||||
title: string;
|
||||
message: string;
|
||||
/** Nothing in it needs anyone: the quiet week. */
|
||||
quiet: boolean;
|
||||
}
|
||||
|
||||
interface Section {
|
||||
heading: string;
|
||||
lines: string[];
|
||||
/** A section that only reassures ("every server stayed up") doesn't make the week un-quiet. */
|
||||
attention: boolean;
|
||||
}
|
||||
|
||||
/** "2 h 40 min", "35 min", "3 d 4 h". */
|
||||
export function spanWords(minutes: number): string {
|
||||
const m = Math.max(1, Math.round(minutes));
|
||||
if (m < 60) return `${m} min`;
|
||||
const h = Math.floor(m / 60);
|
||||
if (h < 24) return m % 60 && h < 10 ? `${h} h ${m % 60} min` : `${h} h`;
|
||||
const d = Math.floor(h / 24);
|
||||
return h % 24 ? `${d} d ${h % 24} h` : `${d} d`;
|
||||
}
|
||||
|
||||
const plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
||||
|
||||
function listWithMore(lines: string[], max = MAX_LINES): string[] {
|
||||
return lines.length > max ? [...lines.slice(0, max), `…and ${lines.length - max} more`] : lines;
|
||||
}
|
||||
|
||||
function whenWords(date: Date, timezone: string): string {
|
||||
return new Intl.DateTimeFormat("en-GB", { timeZone: timezone, weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(date);
|
||||
}
|
||||
|
||||
function dayWords(date: Date, timezone: string): string {
|
||||
return new Intl.DateTimeFormat("en-GB", { timeZone: timezone, weekday: "short", day: "numeric", month: "short", year: "numeric" }).format(date);
|
||||
}
|
||||
|
||||
export async function buildDigest(now: Date = new Date()): Promise<Digest> {
|
||||
const settings = await getSettings();
|
||||
const tz = settings.notifications.timezone || "UTC";
|
||||
const sections: Section[] = [];
|
||||
|
||||
const serverRows = await db
|
||||
.select({ id: servers.id, name: servers.name, lastSeenAt: servers.lastSeenAt, pendingUpdates: servers.pendingUpdates, updatesPendingSince: servers.updatesPendingSince })
|
||||
.from(servers);
|
||||
const serverName = new Map(serverRows.map((s) => [s.id, s.name]));
|
||||
|
||||
// ── Right now ──
|
||||
try {
|
||||
const report = await getAlerts(false);
|
||||
const active = report.alerts.filter((a) => !a.silenced && a.severity !== "info");
|
||||
const lines: string[] = [];
|
||||
if (active.length === 0) lines.push(report.couldntCheck.length > 0 ? `No active alerts, but ${plural(report.couldntCheck.length, "check")} couldn't run.` : "No active alerts.");
|
||||
else {
|
||||
lines.push(`${report.counts.critical} critical, ${report.counts.warning} warning`);
|
||||
// Things about to expire have a section of their own, with dates; they are counted here but not listed twice.
|
||||
const listed = active.filter((a) => a.category !== "expiry");
|
||||
lines.push(...listWithMore(listed.map((a) => `- ${a.message}`), 5));
|
||||
if (listed.length < active.length) lines.push(`(${plural(active.length - listed.length, "more is", "more are")} about things expiring, below)`);
|
||||
}
|
||||
const held: string[] = [];
|
||||
if (report.counts.silenced > 0) held.push(`${report.counts.silenced} silenced by maintenance`);
|
||||
if (report.counts.grouped > 0) held.push(`${report.counts.grouped} folded under a server that is down`);
|
||||
if (held.length > 0) lines.push(`(${held.join(", ")})`);
|
||||
sections.push({ heading: "Right now", lines, attention: active.length > 0 || report.couldntCheck.length > 0 });
|
||||
} catch (err) {
|
||||
console.error("[digest] couldn't read the alerts:", err);
|
||||
}
|
||||
|
||||
// ── Uptime ──
|
||||
try {
|
||||
const uptime = await getUptime(now, DIGEST_DAYS);
|
||||
const integrationName = new Map((await db.select({ id: integrations.id, name: integrations.name }).from(integrations)).map((i) => [i.id, i.name]));
|
||||
const rows: { name: string; down: number; percent: number }[] = [];
|
||||
let measured = 0;
|
||||
for (const [id, series] of Object.entries(uptime.servers)) {
|
||||
measured++;
|
||||
const down = series.buckets.reduce((n, b) => n + b.d, 0);
|
||||
if (down > 0) rows.push({ name: serverName.get(Number(id)) ?? `server ${id}`, down, percent: series.percent });
|
||||
}
|
||||
for (const [id, series] of Object.entries(uptime.integrations)) {
|
||||
measured++;
|
||||
const down = series.buckets.reduce((n, b) => n + b.d, 0);
|
||||
if (down > 0) rows.push({ name: integrationName.get(Number(id)) ?? `integration ${id}`, down, percent: series.percent });
|
||||
}
|
||||
if (measured > 0) {
|
||||
rows.sort((a, b) => b.down - a.down);
|
||||
sections.push({
|
||||
heading: `Uptime, last ${DIGEST_DAYS} days`,
|
||||
lines: rows.length === 0 ? ["Everything stayed up."] : listWithMore(rows.map((r) => `- ${r.name}: ${r.percent}% (${spanWords(r.down)} down)`)),
|
||||
attention: rows.length > 0,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[digest] couldn't read the uptime:", err);
|
||||
}
|
||||
|
||||
// ── What happened ──
|
||||
try {
|
||||
const changes = await getChangesSince({ since: new Date(now.getTime() - DIGEST_DAYS * DAY_MS), now, actorId: 0, canSeeAudit: false });
|
||||
if (changes.events.length > 0) {
|
||||
sections.push({ heading: "What happened", lines: listWithMore(changes.events.map((e) => `- ${e.title}`)), attention: changes.events.some((e) => e.tone === "bad") });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[digest] couldn't read what happened:", err);
|
||||
}
|
||||
|
||||
// ── Disks heading for full ──
|
||||
try {
|
||||
const { diskForecastDays, diskUsagePercent } = settings.healthChecks;
|
||||
if (diskForecastDays > 0) {
|
||||
const lines: string[] = [];
|
||||
for (const s of serverRows) {
|
||||
for (const f of disksFillingSoon(await getServerMetrics(s.id, 14, now), diskForecastDays, diskUsagePercent)) {
|
||||
lines.push(`- ${s.name}: ${f.mount} is ${Math.round(f.latest)}% full and filling by about ${f.perDay.toFixed(1)} points a day — full in about ${plural(f.daysToFull, "day")}`);
|
||||
}
|
||||
}
|
||||
if (lines.length > 0) sections.push({ heading: "Disks heading for full", lines: listWithMore(lines), attention: true });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[digest] couldn't read the disk forecasts:", err);
|
||||
}
|
||||
|
||||
// ── About to expire ──
|
||||
try {
|
||||
const expiring: { daysLeft: number; text: string }[] = [];
|
||||
for (const s of await db.select().from(secrets)) {
|
||||
const status = computeSecretStatus(s.expiryDate, s.warnDays, now);
|
||||
if (status.status === "expired") expiring.push({ daysLeft: status.daysLeft, text: `Secret "${s.name}" expired ${plural(Math.abs(status.daysLeft), "day")} ago` });
|
||||
else if (status.status === "expiring") expiring.push({ daysLeft: status.daysLeft, text: `Secret "${s.name}" expires in ${plural(status.daysLeft, "day")} (${s.expiryDate})` });
|
||||
}
|
||||
for (const d of (await collectDomainAlerts(now)).expiring) {
|
||||
expiring.push({ daysLeft: d.daysLeft, text: d.daysLeft < 0 ? `Domain ${d.name} expired ${plural(Math.abs(d.daysLeft), "day")} ago` : `Domain ${d.name} expires in ${plural(d.daysLeft, "day")} (${d.expiresAt})` });
|
||||
}
|
||||
if (expiring.length > 0) {
|
||||
expiring.sort((a, b) => a.daysLeft - b.daysLeft);
|
||||
sections.push({ heading: "Expiring", lines: listWithMore(expiring.map((e) => `- ${e.text}`)), attention: true });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[digest] couldn't read what is expiring:", err);
|
||||
}
|
||||
|
||||
// ── Updates waiting ──
|
||||
try {
|
||||
const waiting = serverRows
|
||||
.map((s) => ({ name: s.name, updates: parsePendingUpdates(s.pendingUpdates), since: s.updatesPendingSince }))
|
||||
.filter((s) => s.updates && s.updates.count > 0);
|
||||
if (waiting.length > 0) {
|
||||
const security = waiting.reduce((n, s) => n + (s.updates!.security ?? 0), 0);
|
||||
const restarts = waiting.filter((s) => s.updates!.rebootRequired).length;
|
||||
const oldest = waiting.filter((s) => s.since).sort((a, b) => Date.parse(a.since!) - Date.parse(b.since!))[0];
|
||||
const lines = [`${plural(waiting.length, "server")} ${waiting.length === 1 ? "has" : "have"} updates waiting${security > 0 ? ` (${plural(security, "security fix", "security fixes")} among them)` : ""}.`];
|
||||
if (restarts > 0) lines.push(`${plural(restarts, "server")} ${restarts === 1 ? "needs" : "need"} a restart.`);
|
||||
if (oldest) lines.push(`Longest wait: ${oldest.name}, ${spanWords((now.getTime() - Date.parse(oldest.since!)) / 60_000)}.`);
|
||||
const withSecurity = waiting.filter((s) => (s.updates!.security ?? 0) > 0).sort((a, b) => (b.updates!.security ?? 0) - (a.updates!.security ?? 0));
|
||||
lines.push(...listWithMore(withSecurity.map((s) => `- ${s.name}: ${s.updates!.count} waiting, ${s.updates!.security} security`), 5));
|
||||
sections.push({ heading: "Updates waiting", lines, attention: security > 0 });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[digest] couldn't read the pending updates:", err);
|
||||
}
|
||||
|
||||
// ── Planned ──
|
||||
try {
|
||||
const horizon = now.getTime() + DIGEST_DAYS * DAY_MS;
|
||||
const groups = new Map<string, { start: string; end: string; reason: string | null; names: string[] }>();
|
||||
for (const w of await listUpcomingWindows(now)) {
|
||||
if (Date.parse(w.startedAt) > horizon) continue;
|
||||
const target = await describeTarget(w.targetType, w.targetId);
|
||||
if (!target) continue;
|
||||
const key = `${w.startedAt}|${w.endsAt}|${w.reason ?? ""}`;
|
||||
const g = groups.get(key) ?? { start: w.startedAt, end: w.endsAt, reason: w.reason, names: [] };
|
||||
g.names.push(target.name);
|
||||
groups.set(key, g);
|
||||
}
|
||||
if (groups.size > 0) {
|
||||
const lines = [...groups.values()]
|
||||
.sort((a, b) => a.start.localeCompare(b.start))
|
||||
.map((g) => {
|
||||
const sorted = [...g.names].sort((a, b) => a.localeCompare(b));
|
||||
const names = sorted.length <= 3 ? sorted.join(", ") : `${sorted.slice(0, 3).join(", ")} and ${sorted.length - 3} more`;
|
||||
return `- ${whenWords(new Date(g.start), tz)}, ${spanWords((Date.parse(g.end) - Date.parse(g.start)) / 60_000)}: ${names}${g.reason ? ` — ${g.reason}` : ""}`;
|
||||
});
|
||||
sections.push({ heading: "Planned maintenance", lines: listWithMore(lines, 6), attention: false });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[digest] couldn't read the planned maintenance:", err);
|
||||
}
|
||||
|
||||
const quiet = !sections.some((s) => s.attention);
|
||||
const envName = env.environment?.name;
|
||||
const title = `Homelab weekly digest${envName ? ` (${envName})` : ""}`;
|
||||
const body = sections.map((s) => `${s.heading.toUpperCase()}\n${s.lines.join("\n")}`).join("\n\n");
|
||||
const message = `${dayWords(now, tz)}\n${quiet ? "A quiet week: nothing needs attention.\n" : ""}\n${body}`.trim();
|
||||
return { title, message, quiet };
|
||||
}
|
||||
|
||||
/** Builds the digest and sends it through the channels — held with other notifications during quiet hours, unless `immediately`. */
|
||||
export async function sendDigest(options: { immediately?: boolean; now?: Date } = {}): Promise<Digest> {
|
||||
const digest = await buildDigest(options.now);
|
||||
if (options.immediately) await notifyNow(digest.title, digest.message);
|
||||
else await notify(digest.title, digest.message);
|
||||
return digest;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import schedule from "node-schedule";
|
||||
import { getSettings } from "./settingsStore.js";
|
||||
import { sendDigest } from "./weeklyDigest.js";
|
||||
|
||||
let currentJob: schedule.Job | null = null;
|
||||
|
||||
/** The cron rule for "this weekday (0 = Sunday) at HH:MM". */
|
||||
export function cronForDigest(day: number, time: string): string {
|
||||
const [h, m] = time.split(":").map(Number);
|
||||
const d = Number.isInteger(day) && day >= 0 && day <= 6 ? day : 1;
|
||||
return `${Number.isFinite(m) ? m : 0} ${Number.isFinite(h) ? h : 8} * * ${d}`;
|
||||
}
|
||||
|
||||
/** (Re)schedules the weekly digest per the current settings. Call again after they change. */
|
||||
export async function scheduleWeeklyDigest(): Promise<void> {
|
||||
if (currentJob) {
|
||||
currentJob.cancel();
|
||||
currentJob = null;
|
||||
}
|
||||
const { digest, notifications } = await getSettings();
|
||||
if (!digest.enabled) {
|
||||
console.log("[digest] weekly digest is off, nothing scheduled");
|
||||
return;
|
||||
}
|
||||
currentJob = schedule.scheduleJob({ rule: cronForDigest(digest.day, digest.time), tz: notifications.timezone }, () => {
|
||||
sendDigest().catch((err) => console.error("[digest] couldn't send the weekly digest:", err));
|
||||
});
|
||||
console.log(`Weekly digest scheduled: ${cronForDigest(digest.day, digest.time)} (${notifications.timezone})`);
|
||||
}
|
||||
|
||||
export async function initWeeklyDigestScheduler(): Promise<void> {
|
||||
await scheduleWeeklyDigest();
|
||||
}
|
||||
Reference in new issue
Block a user