|
| 1 | +# DBOS CLI |
| 2 | + |
| 3 | +The DBOS CLI is a command-line interface for managing DBOS workflows. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +### From Source |
| 8 | +```bash |
| 9 | +go install github.com/dbos-inc/dbos-transact-golang/cmd/dbos |
| 10 | +``` |
| 11 | + |
| 12 | +### Build Locally |
| 13 | +```bash |
| 14 | +go build -o dbos . |
| 15 | +``` |
| 16 | + |
| 17 | +## Configuration |
| 18 | + |
| 19 | +### Database URL Configuration |
| 20 | + |
| 21 | +The CLI requires a DBOS system database URL to operate. The URL is resolved in the following order of precedence: |
| 22 | + |
| 23 | +1. **Command-line flag**: `--db-url` or `-D` flag |
| 24 | +2. **Configuration file**: `database_url` field in `dbos-config.yaml` |
| 25 | +3. **Environment variable**: `DBOS_SYSTEM_DATABASE_URL` |
| 26 | + |
| 27 | +Example: |
| 28 | +```bash |
| 29 | +# Using command-line flag (highest priority) |
| 30 | +dbos migrate --db-url postgres://user:pass@localhost/mydb |
| 31 | + |
| 32 | +# Using config file (dbos-config.yaml) |
| 33 | +database_url: postgres://user:pass@localhost/mydb |
| 34 | + |
| 35 | +# Using environment variable (lowest priority) |
| 36 | +export DBOS_SYSTEM_DATABASE_URL=postgres://user:pass@localhost/mydb |
| 37 | +dbos migrate |
| 38 | +``` |
| 39 | + |
| 40 | +### Configuration File |
| 41 | + |
| 42 | +The CLI uses a `dbos-config.yaml` file for configuration. By default, it looks for this file in the current directory. You can specify a different config file using the `--config` flag. |
| 43 | + |
| 44 | +```yaml |
| 45 | +name: my-dbos-app |
| 46 | +database_url: ${DBOS_SYSTEM_DATABASE_URL} |
| 47 | + |
| 48 | +runtimeConfig: |
| 49 | + start: |
| 50 | + - go run . |
| 51 | + |
| 52 | +database: |
| 53 | + migrate: |
| 54 | + - echo "Running migrations..." |
| 55 | +``` |
| 56 | +
|
| 57 | +## Global Options |
| 58 | +
|
| 59 | +These options are available for all commands: |
| 60 | +
|
| 61 | +- `-D, --db-url <url>` - Your DBOS system database URL |
| 62 | +- `--config <file>` - Config file (default: dbos-config.yaml) |
| 63 | +- `--verbose` - Enable verbose mode (DEBUG level logging) |
| 64 | + |
| 65 | +## Commands |
| 66 | + |
| 67 | +### `dbos init [project-name]` |
| 68 | +Initialize a new DBOS application from a template. |
| 69 | + |
| 70 | +**Usage:** |
| 71 | +```bash |
| 72 | +dbos init myapp |
| 73 | +``` |
| 74 | + |
| 75 | +Creates a new DBOS application with: |
| 76 | +- `main.go` - Entry point with example workflow |
| 77 | +- `go.mod` - Go module file |
| 78 | +- `dbos-config.yaml` - DBOS configuration |
| 79 | + |
| 80 | +### `dbos migrate` |
| 81 | +Create DBOS system tables in your database. This command runs the migration commands specified in the `database.migrate` section of your config file. |
| 82 | + |
| 83 | +**Options:** |
| 84 | +- `-r, --app-role <role>` - The role with which you will run your DBOS application |
| 85 | + |
| 86 | +**Usage:** |
| 87 | +```bash |
| 88 | +dbos migrate |
| 89 | +dbos migrate --app-role myapp_role |
| 90 | +``` |
| 91 | + |
| 92 | +The migrate commands are defined in `dbos-config.yaml`: |
| 93 | +```yaml |
| 94 | +database: |
| 95 | + migrate: |
| 96 | + - echo "Running migrations..." |
| 97 | + - go run ./migrations |
| 98 | +``` |
| 99 | + |
| 100 | +### `dbos reset` |
| 101 | +Reset the DBOS system database, deleting metadata about past workflows and steps. _This is a permanent, destructive action!_ |
| 102 | + |
| 103 | +**Options:** |
| 104 | +- `-y, --yes` - Skip confirmation prompt |
| 105 | + |
| 106 | +**Usage:** |
| 107 | +```bash |
| 108 | +dbos reset |
| 109 | +dbos reset --yes # Skip confirmation |
| 110 | +``` |
| 111 | + |
| 112 | +### `dbos start` |
| 113 | +Start your DBOS application using the start commands defined in the `runtimeConfig.start` section of your `dbos-config.yaml`. |
| 114 | + |
| 115 | +**Usage:** |
| 116 | +```bash |
| 117 | +dbos start |
| 118 | +``` |
| 119 | + |
| 120 | +The start commands are defined in `dbos-config.yaml`: |
| 121 | +```yaml |
| 122 | +runtimeConfig: |
| 123 | + start: |
| 124 | + - go run . |
| 125 | + # Can have multiple commands that run in sequence |
| 126 | +``` |
| 127 | + |
| 128 | +### `dbos postgres` |
| 129 | +Manage a local PostgreSQL database with Docker for development. |
| 130 | + |
| 131 | +#### `dbos postgres start` |
| 132 | +Start a local Postgres database container with pgvector extension. |
| 133 | + |
| 134 | +**Usage:** |
| 135 | +```bash |
| 136 | +dbos postgres start |
| 137 | +``` |
| 138 | + |
| 139 | +Creates a PostgreSQL container with: |
| 140 | +- Container name: `dbos-db` |
| 141 | +- Port: 5432 |
| 142 | +- Default database: `dbos` |
| 143 | +- Default user: `postgres` |
| 144 | +- Default password: `dbos` |
| 145 | + |
| 146 | +#### `dbos postgres stop` |
| 147 | +Stop the local Postgres database container. |
| 148 | + |
| 149 | +**Usage:** |
| 150 | +```bash |
| 151 | +dbos postgres stop |
| 152 | +``` |
| 153 | + |
| 154 | +### `dbos workflow` |
| 155 | +Manage DBOS workflows. |
| 156 | + |
| 157 | +#### `dbos workflow list` |
| 158 | +List workflows for your application. |
| 159 | + |
| 160 | +**Options:** |
| 161 | +- `-l, --limit <number>` - Limit the results returned (default: 10) |
| 162 | +- `-o, --offset <number>` - Offset for pagination |
| 163 | +- `-S, --status <status>` - Filter by status (PENDING, SUCCESS, ERROR, ENQUEUED, CANCELLED, or MAX_RECOVERY_ATTEMPTS_EXCEEDED) |
| 164 | +- `-n, --name <name>` - Retrieve workflows with this name |
| 165 | +- `-u, --user <user>` - Retrieve workflows run by this user |
| 166 | +- `-v, --application-version <version>` - Retrieve workflows with this application version |
| 167 | +- `-s, --start-time <timestamp>` - Retrieve workflows starting after this timestamp (ISO 8601) |
| 168 | +- `-e, --end-time <timestamp>` - Retrieve workflows starting before this timestamp (ISO 8601) |
| 169 | +- `-q, --queue <queue>` - Retrieve workflows on this queue |
| 170 | +- `-Q, --queues-only` - Retrieve only queued workflows |
| 171 | +- `-d, --sort-desc` - Sort the results in descending order (older first) |
| 172 | + |
| 173 | +**Usage:** |
| 174 | +```bash |
| 175 | +dbos workflow list |
| 176 | +dbos workflow list --limit 50 --status SUCCESS |
| 177 | +dbos workflow list --name "ProcessOrder" --user "admin" |
| 178 | +``` |
| 179 | + |
| 180 | +#### `dbos workflow get [workflow-id]` |
| 181 | +Retrieve the status of a specific workflow. |
| 182 | + |
| 183 | +**Usage:** |
| 184 | +```bash |
| 185 | +dbos workflow get abc123def456 |
| 186 | +``` |
| 187 | + |
| 188 | +Returns detailed information about the workflow including its status, start time, end time, and other metadata. |
| 189 | + |
| 190 | +#### `dbos workflow steps [workflow-id]` |
| 191 | +List the steps of a workflow. |
| 192 | + |
| 193 | +**Usage:** |
| 194 | +```bash |
| 195 | +dbos workflow steps abc123def456 |
| 196 | +``` |
| 197 | + |
| 198 | +Shows all the steps executed within a workflow, their status, and execution details. |
| 199 | + |
| 200 | +#### `dbos workflow cancel [workflow-id]` |
| 201 | +Cancel a workflow so it is no longer automatically retried or restarted. |
| 202 | + |
| 203 | +**Usage:** |
| 204 | +```bash |
| 205 | +dbos workflow cancel abc123def456 |
| 206 | +``` |
| 207 | + |
| 208 | +#### `dbos workflow resume [workflow-id]` |
| 209 | +Resume a workflow that has been cancelled. |
| 210 | + |
| 211 | +**Usage:** |
| 212 | +```bash |
| 213 | +dbos workflow resume abc123def456 |
| 214 | +``` |
| 215 | + |
| 216 | +#### `dbos workflow fork [workflow-id]` |
| 217 | +Fork a workflow from the beginning or from a specific step. |
| 218 | + |
| 219 | +**Options:** |
| 220 | +- `-s, --step <number>` - Restart from this step (default: 1) |
| 221 | +- `-f, --forked-workflow-id <id>` - Custom workflow ID for the forked workflow |
| 222 | +- `-a, --application-version <version>` - Application version for the forked workflow |
| 223 | + |
| 224 | +**Usage:** |
| 225 | +```bash |
| 226 | +dbos workflow fork abc123def456 |
| 227 | +dbos workflow fork abc123def456 --step 3 |
| 228 | +dbos workflow fork abc123def456 --forked-workflow-id custom-id-123 |
| 229 | +``` |
| 230 | + |
| 231 | +### `dbos version` |
| 232 | +Show the version and exit. |
| 233 | + |
| 234 | +**Usage:** |
| 235 | +```bash |
| 236 | +dbos version |
| 237 | +``` |
| 238 | + |
| 239 | +## License |
| 240 | + |
| 241 | +See the main project LICENSE file for details. |
0 commit comments