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>
This commit is contained in:
parent
fc80e66ad4
commit
32c5fbde8f
25 changed files with 614 additions and 6 deletions
|
|
@ -6,6 +6,8 @@ import { createServer, type IncomingMessage, type ServerResponse } from "node:ht
|
|||
import { createReadStream, statSync } from "node:fs";
|
||||
import { join, extname, resolve } from "node:path";
|
||||
import { setupYjsWebSocket } from "./app/lib/yjs-server.ts";
|
||||
import { createBoss, startWorker } from "@trails-cool/jobs";
|
||||
import { expireSessionsJob } from "./app/jobs/expire-sessions.ts";
|
||||
import postgres from "postgres";
|
||||
|
||||
const sentryEnvironment = process.env.CI ? "ci" : (process.env.NODE_ENV ?? "development");
|
||||
|
|
@ -113,7 +115,11 @@ const server = createServer((req, res) => {
|
|||
|
||||
setupYjsWebSocket(server);
|
||||
|
||||
server.listen(port, () => {
|
||||
server.listen(port, async () => {
|
||||
logger.info({ port }, "Planner server listening");
|
||||
logger.info({ port, path: "/sync/:sessionId" }, "Yjs WebSocket available");
|
||||
|
||||
const boss = createBoss(process.env.DATABASE_URL ?? "postgres://trails:trails@localhost:5432/trails");
|
||||
await startWorker(boss, [expireSessionsJob]);
|
||||
logger.info("Background job worker started");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue