Configuration
Configuring DBOS
To configure DBOS, pass in a configuration with DBOS.setConfig before you call DBOS.launch.
For example:
DBOS.setConfig({
name: 'my-app',
systemDatabaseUrl: process.env.DBOS_SYSTEM_DATABASE_URL,
});
await DBOS.launch();
A configuration object has the following fields.
All fields except name are optional.
export interface DBOSConfig {
name?: string;
applicationVersion?: string;
executorID?: string;
systemDatabaseUrl?: string;
systemDatabasePoolSize?: number;
systemDatabasePollingConcurrency?: number;
systemDatabaseSchemaName?: string;
systemDatabasePool?: Pool;
tracingEnabled?: boolean;
otelAttributeFormat?: 'legacy' | 'semconv';
logLevel?: string;
logger?: DLogger;
enableOTLP?: boolean;
otlpLogsEndpoints?: string[];
otlpTracesEndpoints?: string[];
runAdminServer?: boolean;
adminPort?: number;
listenQueues?: (WorkflowQueue | string)[];
schedulerPollingIntervalMs?: number;
serializer?: DBOSSerializer;
}
Application Settings
- name: Your application's name.
- applicationVersion: The code version for this application and its workflows. Workflow versioning is documented here.
- executorID: A unique process ID used to identify the application instance in distributed environments. If using DBOS Conductor or Cloud, this is set automatically.
Database Connection Settings
- systemDatabaseUrl: A connection string to a Postgres database in which DBOS can store internal state. The supported format is:
postgresql://[username]:[password]@[hostname]:[port]/[database name]
The default is:
postgresql://postgres:dbos@localhost:5432/[application name]_dbos_sys
If the Postgres database referenced by this connection string does not exist, DBOS will attempt to create it.
- systemDatabasePoolSize: The size of the connection pool used for the DBOS system database. Defaults to 10.
- systemDatabasePollingConcurrency: The maximum number of database-backed polling reads from wait operations (such as
getResult,waitAll,waitFirst,recv, andgetEvent) that may run concurrently against the system database pool. This prevents high-fan-out polling from checking out every connection in the pool and starving control-plane operations (such as enqueue/dequeue, status writes, recovery, and cancellation). Defaults to half thesystemDatabasePoolSize(minimum 1). Set to a non-positive value to disable the limit. - systemDatabaseSchemaName: Postgres schema name for DBOS system tables. Defaults to
dbos. - systemDatabasePool: A custom
node-postgresconnection pool to use to connect to your system database. If provided, DBOS will not create a connection pool but use this instead.
Logging and Tracing Settings
- tracingEnabled: Enable DBOS trace generation. Use this with an external OTLP
TracerProvider. Traces will be collected and exported by your existing provider. Tutorial here. - otelAttributeFormat: Naming convention for DBOS-emitted span attributes. Defaults to
'legacy', which emits the original camelCase names (operationUUID,executorID, …) for backward compatibility. Set to'semconv'to emit OTel-style names under thedbos.*namespace (dbos.operation.workflow_id,dbos.executor.id, …), which follow the OTel attribute naming spec and avoid colliding with attributes set by other instrumentation. The flag is process-wide; user-supplied attributes are passed through verbatim either way. - logLevel: Configure the DBOS logger severity. Defaults to
info. - logger: A custom logger implementing the
DLoggerinterface, to which DBOS directs all its internal logging, replacing the built-in console and OTLP log sinks. When set,logLeveldoes not filter calls to it (level routing is the logger's job), logs are not exported over OTLP even ifenableOTLPis on (traces are unaffected), and DBOS never flushes or closes it (the caller owns its lifecycle). - enableOTLP: Enable the built-in DBOS OpenTelemetry
TracerProvider. Defaults to False. Do not set if using an external OTLPTracerProvider. - otlpTracesEndpoints: If using the built-in DBOS OpenTelemetry
TracerProvider, a list of receivers to which to send traces. - otlpLogsEndpoints: If using the built-in DBOS OpenTelemetry
TracerProvider, a list of receivers to which to send logs.
Admin Server Settings
- runAdminServer: Whether to run an HTTP admin server for workflow management operations. Defaults to True.
- adminPort: The port on which the admin server runs. Defaults to 3001.
Queue Settings
- listenQueues: This process should only listen to (dequeue and execute workflows from) these queues. Each entry is either a
WorkflowQueueinstance or a queue name. Names that do not match any queue at launch are deferred — a database-backed queue registered later under that name will be picked up automatically.
Scheduler Settings
- schedulerPollingIntervalMs: How frequently (in milliseconds) the scheduler polls the database for schedule changes. Defaults to 30000 (30 seconds).
Serialization Settings
- serializer: A custom serializer for the system database. See the custom serialization section for details.
Custom Serialization
DBOS must serialize data such as workflow inputs and outputs and step outputs to store it in the system database. By default, data is serialized with JSON, but you can optionally supply a custom serializer through DBOS configuration. A custom serializer must match this interface:
interface DBOSSerializer {
stringify: (obj: unknown) => string | Promise<string>;
parse: (text: string | null | undefined) => unknown | Promise<unknown>;
name: () => string; // `name` is stored with the resulting string to ensure the correct deserializer is used.
}
Both stringify and parse may be synchronous or asynchronous.
For example, here is how to configure DBOS to use a Base64-encoded JSON serializer:
import { DBOS, DBOSSerializer } from "@dbos-inc/dbos-sdk";
const base64Serializer: DBOSSerializer = {
parse: (text) => {
// Parsers must always return null when receiving null or undefined
if (text === null || text === undefined) return null;
return JSON.parse(Buffer.from(text, 'base64').toString());
},
stringify: (obj) => {
// JSON.stringify doesn't handle undefined, so convert it to null instead
if (obj === undefined) obj = null;
return Buffer.from(JSON.stringify(obj)).toString('base64');
},
name: () => "simple_json",
};
const config = // ...
config.serializer = base64Serializer;
DBOS.setConfig(config);
await DBOS.launch();
DBOS Configuration File
Some tools in the DBOS ecosystem, including DBOS Cloud and the DBOS CLI, are configured by a dbos-config.yaml file.
Here is an example configuration file with default parameters:
name: my-app
language: node
system_database_url: ${DBOS_SYSTEM_DATABASE_URL}
runtimeConfig:
start:
- node dist/main.js
Configuration File Fields
You can use environment variables for configuration values through the syntax field: ${VALUE}.
Each dbos-config.yaml file has the following fields and sections:
- name: Your application's name. Must match the name supplied to
DBOS.setConfig(). - language: The application language. Must be set to
nodefor TypeScript applications. - system_database_url: The connection string to your DBOS system database.
This connection string is used by the DBOS CLI.
It has the same format as the
system_database_urlyou pass to the DBOS constructor. - runtimeConfig:
- start: (required only in DBOS Cloud) The command(s) with which to start your app. Called from
npx dbos start, which is used to start your app in DBOS Cloud. - setup: (optional) Setup commands to run before your application is built in DBOS Cloud. Used only in DBOS Cloud. Documentation here.
- start: (required only in DBOS Cloud) The command(s) with which to start your app. Called from
Configuration Schema File
There is a schema file available for the DBOS configuration file schema in GitHub. This schema file can be used to provide an improved YAML editing experience for developer tools that leverage it. For example, the Visual Studio Code RedHat YAML extension provides tooltips, statement completion and real-time validation for editing DBOS config files. This extension provides multiple ways to associate a YAML file with its schema. The easiest is to simply add a comment with a link to the schema at the top of the config file:
# yaml-language-server: $schema=https://github.com/dbos-inc/dbos-transact-py/blob/main/dbos/dbos-config.schema.json