Skip to main content
Reference vendor/dbos 4 min read

lifecycle-config


title: Configure and Launch DBOS Properly impact: CRITICAL impactDescription: Application won’t function without proper setup tags: configuration, launch, setup, initialization, migrate, conductor, enterprise, auto-upgrade

Configure and Launch DBOS Properly

Every DBOS application must configure and launch DBOS before running any workflows. All workflows and steps must be registered before calling DBOS.launch().

Incorrect (missing configuration or launch):

import { DBOS } from "@dbos-inc/dbos-sdk";

// No configuration or launch!
async function myWorkflowFn() {
  // This will fail - DBOS is not launched
}
const myWorkflow = DBOS.registerWorkflow(myWorkflowFn);
await myWorkflow();

Correct (configure and launch in main):

import { DBOS } from "@dbos-inc/dbos-sdk";

async function myWorkflowFn() {
  // workflow logic
}
const myWorkflow = DBOS.registerWorkflow(myWorkflowFn);

async function main() {
  DBOS.setConfig({
    name: "my-app",
    applicationVersion: "0.1.0",
    systemDatabaseUrl: process.env.DBOS_SYSTEM_DATABASE_URL,
  });
  await DBOS.launch();
  await myWorkflow();
}

main().catch(console.log);

For scheduled-only applications, create schedules after launch:

async function main() {
  DBOS.setConfig({ name: "my-app", applicationVersion: "0.1.0", systemDatabaseUrl: process.env.DBOS_SYSTEM_DATABASE_URL });
  await DBOS.launch();
  await DBOS.applySchedules([
    { scheduleName: "my-task", workflowFn: scheduledTask, schedule: "* * * * *" },
  ]);
}

DBOSConfig Reference

All fields except name are optional. DBOS.launch() throws DBOSInitializationError if no configuration or no name was provided. DBOS does not read dbos-config.yaml at launch (the DBOS CLI and DBOS Cloud still use it); always configure with DBOS.setConfig.

name identifies which application owns each workflow, queue, schedule, and application version in the system database. Applications sharing a system database must have distinct names, and a process only runs its own application’s workflows.

FieldDescriptionDefault
nameApplication name and ownership key(required)
applicationVersionVersion tag for versioning strategy. Set to "0.1.0" in new applicationsAuto-computed hash
executorIDUnique process ID for distributed environmentsAuto-set by Conductor/Cloud
enablePatchingDeprecated (5.4): DBOS.patch() no longer needs it; it only pins applicationVersion to PATCHING_ENABLED and logs a warning. Set applicationVersion instead—
transactEnterpriseKeyKey entitling the app to DBOS Transact Enterprise features without Conductor. Development only; in production, pass conductorKey to DBOS.launch (it stands in for this key)undefined
autoUpgradeAuto-upgrade every workflow except those registered with autoUpgrade: false (see advanced-patching.md). Requires DBOS Transact Enterprisefalse
autoUpgradeIntervalMsMilliseconds between auto-upgrade passes30000
autoUpgradeGraceMsMilliseconds the latest version must have been the latest before PENDING workflows on older versions are moved (ENQUEUED/DELAYED move without waiting)0
systemDatabaseUrlPostgres connection string for system DBpostgresql://postgres:dbos@localhost:5432/[name]_dbos_sys
systemDatabasePoolSizeSystem DB connection pool size10
systemDatabasePollingConcurrencyMax concurrent database-backed polling reads from wait operations (getResult, waitFirst, recv, getEvent, …), so high-fan-out polling can’t starve enqueue/dequeue, status writes, recovery, and cancellation. Non-positive disables the limitHalf the pool size (min 1)
systemDatabaseSchemaNamePostgres schema for DBOS system tables"dbos"
systemDatabasePoolCustom node-postgres pool (skips pool creation; you own it, shutdown doesn’t close it)undefined
runMigrationsCreate/migrate the system database on launch. Set false if the role can’t run DDL and you migrate with npx dbos schema or DBOS.migrate; launch then only verifies the schematrue
observabilityQueryTimeoutMsStatement timeout for listWorkflows, listQueuedWorkflows, listWorkflowSteps, etc.; exceeding it throws DBOSQueryTimeoutError. <= 0 disables30000
systemDatabaseIdleTransactionTimeoutMsPostgres idle_in_transaction_session_timeout set on the system database connections DBOS creates60000
useListenNotifyUse Postgres LISTEN/NOTIFY to wake recv/getEvent/readStream waiters. Set false if unsupported (e.g., CockroachDB) to poll insteadtrue
notificationCoalesceMsWith useListenNotify, interval over which event/stream notifications are batched10
tracingEnabledGenerate DBOS traces for an external OpenTelemetry TracerProvider—
otelAttributeFormatSpan attribute naming: 'legacy' or 'semconv' (dbos.* names)'legacy'
enableOTLPEnable the built-in DBOS OpenTelemetry TracerProvider and exportfalse (true in DBOS Cloud)
otlpTracesEndpointsOTLP trace receiver URLs (built-in provider only)undefined
otlpLogsEndpointsOTLP log receiver URLs (built-in provider only)undefined
logLevelDBOS logger severity"info"
loggerCustom logger implementing the DLogger interface, to which DBOS directs all its internal logging, replacing the built-in console and OTLP log sinks. error() receives the Error’s message, with its stack (including its cause chain) in metadata.stack and the original Error in metadata.errorundefined
addContextMetadataAppend workflow ID/operation name to console logs from workflows and steps (only when enableOTLP is on)false
listenQueuesNames of the only queues this process dequeues from (string[]). Names not matching a queue at launch are picked up when registeredAll queues owned by this application
maxConcurrentQueueDispatchesMax number of queues this process dequeues from concurrently3
schedulerPollingIntervalMsScheduler polling interval for new schedules (ms)30000
serializerCustom serializer for system databaseDefault (SuperJSON)

Connecting to Conductor

Pass Conductor settings to DBOS.launch (not DBOS.setConfig). Connecting to Conductor requires the @dbos-inc/dbos-enterprise package at the same minor version as @dbos-inc/dbos-sdk (upgrade the two together); without it, DBOS.launch throws DBOSInitializationError when conductorKey is set or the app runs in DBOS Cloud:

npm install @dbos-inc/dbos-enterprise
await DBOS.launch({
  conductorKey: process.env.DBOS_CONDUCTOR_KEY, // API key from the DBOS Console
  // conductorURL: only when self-hosting Conductor
  // conductorExecutorMetadata: { region: "us-east-1" },
  // conductorMetadataOnlyMode: true, // never send workflow data, only metadata
});

The same package provides the DBOS Transact Enterprise feature auto-upgrade (autoUpgrade, see advanced-patching.md). It also requires a key whose organization is entitled to it, which DBOS.launch checks with Conductor: the conductorKey in production or, in development without Conductor, transactEnterpriseKey in DBOS.setConfig (a Conductor API key from the DBOS Console). A missing package, key, or entitlement makes DBOS.launch throw DBOSInitializationError.

Least-Privilege Deployment

By default, DBOS.launch() creates the system database and migrates its tables, which requires DDL privileges. If the app’s database role can’t (or shouldn’t) run DDL, migrate out of band with a privileged user and set runMigrations: false:

# As a privileged user: create/migrate the system tables and grant the app role access
npx dbos schema ${DBOS_SYSTEM_DATABASE_URL} -r my_app_role

# Or emit SQL for a DBA to apply (never connects; must run outside a transaction block)
npx dbos schema --print-migrations all ${DBOS_SYSTEM_DATABASE_URL} > migrations.sql
npx dbos schema --print-user-role -r my_app_role ${DBOS_SYSTEM_DATABASE_URL} > grants.sql

Or run the same migration from code (for example, in a deployment migration script). It creates the database if it does not exist:

// Run with a privileged role
await DBOS.migrate(process.env.ADMIN_SYSTEM_DATABASE_URL!, {
  applicationRole: "my_app_role", // grant this role access to the DBOS schema
  // schemaName: "dbos",
});
DBOS.setConfig({
  name: "my-app",
  systemDatabaseUrl: process.env.DBOS_SYSTEM_DATABASE_URL, // connects as my_app_role
  runMigrations: false,
});
await DBOS.launch();
  • -s, --schema <name> targets a non-default schema (match systemDatabaseSchemaName)
  • --print-migrations <all|NUMBER> prints all migrations (fresh database) or those from a migration number (upgrade)
  • With runMigrations: false, launch only verifies the schema: a missing or outdated system database fails with DBOSInitializationError; a newer schema is accepted
  • npx dbos schema and DBOS.migrate do not migrate datasource tables; see step-transactions.md

Reference: DBOS Configuration