fix(worker): add granular debug logging to isolate startup hang
Add console.log before/after each createQueue() call and dynamic import to pinpoint exactly where the worker startup is blocking.
This commit is contained in:
+17
-6
@@ -127,19 +127,25 @@ export async function reserveWorkerId(queueType: WorkerQueue): Promise<string> {
|
|||||||
|
|
||||||
async function ensureDalpuriSyncQueue(): Promise<void> {
|
async function ensureDalpuriSyncQueue(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
console.log("[worker] Creating DALPURI_FULL_SYNC queue...");
|
||||||
await boss.createQueue(WorkerQueue.DALPURI_FULL_SYNC);
|
await boss.createQueue(WorkerQueue.DALPURI_FULL_SYNC);
|
||||||
} catch {
|
console.log("[worker] DALPURI_FULL_SYNC queue ready");
|
||||||
// Queue may already exist; ignore to keep this idempotent.
|
} catch (err) {
|
||||||
|
console.log("[worker] DALPURI_FULL_SYNC queue already exists (or error):", (err as Error).message);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
console.log("[worker] Creating DALPURI_INCREMENTAL_SYNC queue...");
|
||||||
await boss.createQueue(WorkerQueue.DALPURI_INCREMENTAL_SYNC);
|
await boss.createQueue(WorkerQueue.DALPURI_INCREMENTAL_SYNC);
|
||||||
} catch {
|
console.log("[worker] DALPURI_INCREMENTAL_SYNC queue ready");
|
||||||
// Queue may already exist; ignore to keep this idempotent.
|
} catch (err) {
|
||||||
|
console.log("[worker] DALPURI_INCREMENTAL_SYNC queue already exists (or error):", (err as Error).message);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
console.log("[worker] Creating REFRESH_SALES_METRICS queue...");
|
||||||
await boss.createQueue(WorkerQueue.REFRESH_SALES_METRICS);
|
await boss.createQueue(WorkerQueue.REFRESH_SALES_METRICS);
|
||||||
} catch {
|
console.log("[worker] REFRESH_SALES_METRICS queue ready");
|
||||||
// Queue may already exist; ignore to keep this idempotent.
|
} catch (err) {
|
||||||
|
console.log("[worker] REFRESH_SALES_METRICS queue already exists (or error):", (err as Error).message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,11 +193,16 @@ if (import.meta.main) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
console.log("[worker] PgBoss started successfully");
|
console.log("[worker] PgBoss started successfully");
|
||||||
|
console.log("[worker] Ensuring sync queues...");
|
||||||
await ensureDalpuriSyncQueue();
|
await ensureDalpuriSyncQueue();
|
||||||
|
console.log("[worker] Sync queues ready");
|
||||||
|
|
||||||
// Register job handler for DALPURI_FULL_SYNC
|
// Register job handler for DALPURI_FULL_SYNC
|
||||||
|
console.log("[worker] Importing sync-manager...");
|
||||||
const { enqueueDalpuriFullSync } = await import("./modules/workers/sync-manager");
|
const { enqueueDalpuriFullSync } = await import("./modules/workers/sync-manager");
|
||||||
|
console.log("[worker] Importing dalpuri-sync...");
|
||||||
const { executeIncrementalSync } = await import("./modules/workers/dalpuri-sync");
|
const { executeIncrementalSync } = await import("./modules/workers/dalpuri-sync");
|
||||||
|
console.log("[worker] Importing incremental-sync...");
|
||||||
const { enqueueIncrementalSync } = await import("./modules/workers/incremental-sync");
|
const { enqueueIncrementalSync } = await import("./modules/workers/incremental-sync");
|
||||||
await boss.work(WorkerQueue.DALPURI_FULL_SYNC, async () => {
|
await boss.work(WorkerQueue.DALPURI_FULL_SYNC, async () => {
|
||||||
const socket = await ensureManagerSocketReady();
|
const socket = await ensureManagerSocketReady();
|
||||||
|
|||||||
Reference in New Issue
Block a user