Reference

CLI & generators

The pgbus command-line interface and every Rails generator, at a glance.

The CLI#

CommandDoes
pgbus startBoot the supervisor (workers, dispatcher, scheduler, consumers).
pgbus statusShow running processes.
pgbus queuesList queues with depth and metrics.
pgbus dlqInspect and drain dead-letter queues (see below).
pgbus doctorPreflight diagnostics — gates a deploy or CI run (see below).
pgbus mcpStart the read-only MCP diagnostic server over stdio.
pgbus versionPrint the version.
pgbus helpShow help.

start flags#

Split roles and capsules across processes.

FlagDoes
--workers-onlyRun only worker processes.
--scheduler-onlyRun only the recurring-task scheduler.
--dispatcher-onlyRun only the maintenance dispatcher.
--capsule NAMEBoot a single named capsule.
--execution-mode asyncRun jobs as fibers instead of threads.
The role flags are mutually exclusive, and the auto-tuned pool_size follows the role — a scheduler-only process opens only the connections it needs. See Running workers.

pgbus doctor#

One preflight command for deploy/CI gating.

pgbus doctor (and the equivalent rake pgbus:doctor) runs six checks and prints a report — config validity, database connectivity, PGMQ schema version, configured-queue existence, LISTEN/NOTIFY triggers, and process liveness (the same OK / DEGRADED / STALLED verdict as the MCP pgbus_health tool). It never touches PGMQ or PostgreSQL directly outside Pgbus::Client, and it never raises — a broken environment turns every probe into a failed check instead of a crash.

CheckFails when
ConfigurationConfiguration#validate! raises.
DatabaseThe DB is unreachable (a plain SELECT 1 via Client#ping).
PGMQ schemaThe schema is missing, untracked, or behind the vendored version (warn).
QueuesA configured queue has no PGMQ table.
LISTEN/NOTIFYA configured queue is missing its insert trigger (warn — falls back to polling).
Process livenessSTALLED (silent worker wedge); DEGRADED only warns.

The report ends with a resolved-config summary (queue prefix, pool size, roles, capsules) with any password redacted from database_url / connection_params.

pgbus doctor        # prints the report; exit 1 if any check failed
rake pgbus:doctor   # same checks, for a Rake-based deploy pipeline
Warnings (an outdated PGMQ schema, a missing NOTIFY trigger) don't fail the exit code — only a failed check does. Wire pgbus doctor into your deploy pipeline or CI to gate on a broken environment before it reaches production.

pgbus dlq#

Dead-letter management from a headless deployment.

Every subcommand routes through Web::DataSource, so retry/discard semantics are identical to the dashboard — origin-queue re-enqueue, transactional produce+delete, lock release on discard — with zero raw SQL and no direct PGMQ calls.

SubcommandDoes
pgbus dlq list [--page N] [--per-page N]Table of msg_id / DLQ queue / origin queue / read_ct / enqueued_at, plus a total count. Never prints payloads.
pgbus dlq show MSG_IDMessage metadata plus the payload, passed through the dashboard's sensitive-data filter.
pgbus dlq retry MSG_IDRe-enqueue one message to its origin queue.
pgbus dlq retry-allRe-enqueue every dead-letter message; prints the count.
pgbus dlq purge MSG_IDDiscard a single message.
pgbus dlq purge --all --yesDiscard every dead-letter message. Omitting --yes makes no changes and exits 1.
An unknown msg_id or an unknown subcommand exits 1. purge --all without --yes is a deliberate safety rail — it refuses to purge and exits 1 rather than prompting.

Core generators#

Every generator accepts --database=pgbus to route its migration to db/pgbus_migrate/ for a separate database.

GeneratorDoes
pgbus:installFull setup — the metadata migrations, the batches table, and a starter initializer.
pgbus:updateConvert a legacy YAML config and add any missing migrations, detecting a separate DB automatically.
pgbus:upgrade_pgmqUpgrade the embedded PGMQ schema to the latest vendored version.

Feature generators#

Add the table for an optional feature.

GeneratorAdds
pgbus:add_recurringRecurring-task tables + a starter recurring.yml.
pgbus:add_outboxThe transactional-outbox table.
pgbus:add_presenceThe stream-presence table.
pgbus:add_queue_statesThe queue pause/resume + circuit-breaker state table.
pgbus:add_uniqueness_keysThe job-uniqueness lock table.
pgbus:add_job_statsThe job-stats table for the Insights dashboard.
pgbus:add_stream_statsThe stream-stats table (opt-in metrics).
A few migration-maintenance generators also ship for existing installs: add_failed_events_index, add_job_stats_latency, add_job_stats_queue_index, and migrate_job_locks. The pgbus:update generator adds whichever of these your database is missing.

Tuning generators#

Re-apply table settings a schema load drops.

GeneratorDoes
pgbus:tune_autovacuumApply aggressive autovacuum settings to the high-churn queue tables.
pgbus:tune_fillfactorTune table fillfactor for existing installations.
Run these after db:schema:load, which drops ALTER TABLE settings. See Performance & tuning.