Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
372 changes: 190 additions & 182 deletions IDEA.md

Large diffs are not rendered by default.

1,290 changes: 663 additions & 627 deletions apps/app/src/routeTree.gen.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"db:migrate": "cd ../../packages/database && pnpm with-env drizzle-kit migrate",
"db:generate": "cd ../../packages/database && pnpm with-env drizzle-kit generate",
"db:push": "cd ../../packages/database && pnpm with-env drizzle-kit push",
"db:studio": "cd ../../packages/database && pnpm with-env drizzle-kit studio",
"db:studio": "cd ../../packages/database && pnpm with-env drizzle-kit studio --host=0.0.0.0",
"with-env": "dotenv -e ../../.env --"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/queue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"exports": {
".": "./src/index.ts",
"./types": "./src/types.ts"
"./types": "./src/types.ts",
"./shutdown": "./src/shutdown.ts"
},
"prettier": "@vidcastx/prettier",
"devDependencies": {
Expand Down
32 changes: 32 additions & 0 deletions packages/queue/src/shutdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Worker } from "bullmq";

/**
* Register SIGINT/SIGTERM/SIGHUP handlers that call `worker.close(true)` once.
*
* BullMQ locks workers with a TTL-based Redis key. If the process dies without
* calling `worker.close()`, the lock sits in Redis for `lockDuration` and blocks
* any other worker from picking up the in-flight job until it expires. On dev
* with `tsx watch`, every file change triggers a restart — without this handler
* the queue visibly stalls for up to 10 minutes each time.
*
* Standard BullMQ shutdown pattern: https://docs.bullmq.io/guide/going-to-production
*/
export function registerWorkerShutdown(worker: Worker, label = worker.name): void {
let shuttingDown = false;

async function handle(signal: NodeJS.Signals): Promise<void> {
if (shuttingDown) return;
shuttingDown = true;
console.warn(`[${label}] ${signal} received — closing worker`);
try {
await worker.close(true);
} catch (error) {
console.error(`[${label}] worker.close failed:`, error);
}
process.exit(0);
}

process.once("SIGINT", () => void handle("SIGINT"));
process.once("SIGTERM", () => void handle("SIGTERM"));
process.once("SIGHUP", () => void handle("SIGHUP"));
}
Loading
Loading