Configuration

Everything worker.config.ts accepts.

worker.config.ts is the single source of truth for a worker. The CLI loads it for dev, build, and start; pass --config <path> to use a different file.

worker.config.ts
import { defineConfig, postgresAdapter } from '@openqueue/sdk';

export default defineConfig({
  namespace: 'my-app',
  dirs: ['./worker'],
  exclude: ['**/*.test.ts'],
  redis: {
    url: process.env.REDIS_URL!,
  },
  concurrency: {
    global: 8,
    queues: { exports: 2 },
  },
  workbench: {
    enabled: true,
    title: 'Jobs',
    basePath: '/workbench',
  },
});

Reference

FieldDescription
namespacePrefix for every Redis key this worker touches. Lets multiple apps share one Redis.
dirsDirectories scanned for exported task() definitions.
tasksExplicit task modules ({ module, export? }) instead of — or alongside — directory scanning.
excludeGlob patterns removed from discovery (tests, fixtures).
redis.urlRedis connection string.
redis.bullPrefixOverride the BullMQ key prefix.
storage.adapterA QueueStorage implementation — use postgresAdapter to persist run history.
drainsSinks for run lifecycle events; consoleDrain() ships in the box, composeDrains() combines several.
concurrency.globalWorker-wide cap on parallel jobs.
concurrency.queuesPer-queue caps, by queue name.
metricsToggle metric collection and key prefix.
workbenchDashboard options — see below.
buildoutDir, extraFiles, external for openqueue build.

Workbench options

FieldDescription
enabledServe the dashboard from this worker.
titleName shown in the dashboard chrome.
basePathMount path, for example /workbench.
readonlyDisable mutating actions (retry, enqueue, pause).
auth{ username, password } for basic auth.
tagFieldsPayload field names that Workbench can extract as filterable tags.

Persistent run history

Redis keeps recent state; Postgres keeps the paper trail. Wire the Drizzle adapter to persist runs, schedules, and alerts:

import { defineConfig, postgresAdapter } from '@openqueue/sdk';
import { db } from './src/db';
import { queueSchema } from './src/queue-schema';

export default defineConfig({
  namespace: 'my-app',
  dirs: ['./worker'],
  redis: { url: process.env.REDIS_URL! },
  storage: {
    adapter: postgresAdapter({ db, schema: queueSchema }),
  },
});

See Persistence for the table definitions, how to generate the Drizzle migrations, and retention patterns.

On this page