trails/apps/planner/app/jobs/expire-sessions.ts
Ullrich Schäfer 32c5fbde8f Add pg-boss background job queue with session expiry
Add @trails-cool/jobs package wrapping pg-boss for durable background job
execution using the existing PostgreSQL database. Wire up planner session
expiry as the first scheduled job (hourly, 7-day TTL) — this was previously
dead code that never ran. Add placeholder worker to journal for future
Komoot import and federation jobs.

Infrastructure: grant grafana_reader access to pgboss schema, add job queue
health panels to Service Health dashboard, add failed job alert.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 21:17:24 +02:00

15 lines
467 B
TypeScript

import type { JobDefinition } from "@trails-cool/jobs";
import { expireSessions } from "../lib/sessions.ts";
import { logger } from "../lib/logger.server.ts";
export const expireSessionsJob: JobDefinition = {
name: "expire-sessions",
cron: "0 * * * *",
retryLimit: 2,
expireInSeconds: 60,
async handler() {
const count = await expireSessions(7);
logger.info({ count }, "expired stale planner sessions");
return { expiredCount: count };
},
};