Quickstart
@quik/queue-worker's onBoot hook only runs inside a Node worker_threads worker (it no-ops on the main thread). Include the module in a dedicated worker entry file that boots the app inside the thread:
// worker-entry.ts
import { boot, setup } from '@quik/bootstrap';
import { Module as DatabaseModule } from '@quik/database';
import { Module as QueueWorkerModule } from '@quik/queue-worker';
await setup({ modules: [DatabaseModule, QueueWorkerModule] });
await boot();
Spawn one or more workers from the main process:
import { Worker } from 'node:worker_threads';
new Worker(new URL('./worker-entry.js', import.meta.url), {
workerData: {
intervalMs: 2000,
batchSize: 10,
workerName: 'queue-worker:1'
}
});
Notes
workerData.intervalMs/batchSizeoverridescheduler.queue.intervalMs/scheduler.queue.batchSizefor that specific worker; omit them to use the shared config.@quik/databaseis a required dependency — the worker closes its database connection cleanly on shutdown.