Download src/server/queue/boss.ts from bhyve/auto-lms: direct link, hf CLI and curl.
- Browser
- Download file 643 Bytes
-
https://huggingface.co/spaces/bhyve/auto-lms/resolve/main/src/server/queue/boss.ts
- Command line
-
hf download hf://spaces/bhyve/auto-lms/src/server/queue/boss.ts
-
curl -L -o boss.ts https://huggingface.co/spaces/bhyve/auto-lms/resolve/main/src/server/queue/boss.ts
643 Bytes
| import PgBoss from 'pg-boss'; | |
| // Single pg-boss instance per process, started lazily. pg-boss manages its own | |
| // 'pgboss' schema in the same Postgres database — no Redis required. | |
| let bossPromise: Promise<PgBoss> | null = null; | |
| export async function getBoss(): Promise<PgBoss> { | |
| if (!bossPromise) { | |
| const connectionString = process.env.DATABASE_URL; | |
| if (!connectionString) { | |
| throw new Error('DATABASE_URL is not set'); | |
| } | |
| const boss = new PgBoss({ connectionString }); | |
| boss.on('error', (err) => console.error('[pg-boss] error', err)); | |
| bossPromise = boss.start().then(() => boss); | |
| } | |
| return bossPromise; | |
| } | |