|
| 1 | +# DBOS CLI |
| 2 | + |
| 3 | +The DBOS CLI is a command-line interface for managing DBOS workflows. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +DBOS CLI is distributed as a JAR with dependencies (also known as a fat or uber JAR). |
| 8 | +It is run from the command line with the `-jar` option of the [`java` command](https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html). |
| 9 | + |
| 10 | +```shell |
| 11 | +$ java -jar dbos.jar --version |
| 12 | +dbos v0.7.0 |
| 13 | +``` |
| 14 | + |
| 15 | +## Configuration |
| 16 | + |
| 17 | +### Database Connection Configuration |
| 18 | + |
| 19 | +Many of the DBOS CLI commands require a DBOS system database connection to operate. |
| 20 | +The DBOS system database connection is specified via a JDBC URL plus a username and password. |
| 21 | +These values can be specified on the command line or via environment variables. |
| 22 | + |
| 23 | +* System Database JDBC URL |
| 24 | + * `--db-url` / `-D` flag |
| 25 | + * `DBOS_SYSTEM_JDBC_URL` environment variable |
| 26 | +* System Database user |
| 27 | + * `--db-user` / `-U` flag |
| 28 | + * `PGUSER` environment variable |
| 29 | +* System Database password |
| 30 | + * `--db-password` / `-P` flag |
| 31 | + * `PGPASSWORD` environment variable |
| 32 | + |
| 33 | +Example: |
| 34 | +```bash |
| 35 | +# Using command-line flag (highest priority) |
| 36 | +java -jar dbos.jar migrate --db-url jdbc:postgresql://localhost/mydb -U user -P password |
| 37 | + |
| 38 | +# Using environment variable (lowest priority) |
| 39 | +export DBOS_SYSTEM_JDBC_URL=jdbc:postgresql://localhost/mydb |
| 40 | +export PGUSER=user |
| 41 | +export PGPASSWORD=password |
| 42 | +java -jar dbos.jar migrate |
| 43 | +``` |
| 44 | + |
| 45 | +### `dbos migrate` |
| 46 | +Create DBOS system tables in your database. This command runs the migration commands specified in the `database.migrate` section of your config file. |
| 47 | + |
| 48 | +**Options:** |
| 49 | +- `-r, --app-role <role>` - The role with which you will run your DBOS application |
| 50 | + |
| 51 | +**Usage:** |
| 52 | +```bash |
| 53 | +java -jar dbos.jar migrate |
| 54 | +java -jar dbos.jar migrate --app-role myapp_role |
| 55 | +``` |
| 56 | + |
| 57 | +### `dbos reset` |
| 58 | +Reset the DBOS system database, deleting metadata about past workflows and steps. _This is a permanent, destructive action!_ |
| 59 | + |
| 60 | +**Options:** |
| 61 | +- `-y, --yes` - Skip confirmation prompt |
| 62 | + |
| 63 | +**Usage:** |
| 64 | +```bash |
| 65 | +java -jar dbos.jar reset |
| 66 | +java -jar dbos.jar reset --yes # Skip confirmation |
| 67 | +``` |
| 68 | + |
| 69 | +### `dbos postgres` |
| 70 | +Manage a local PostgreSQL database with Docker for development. |
| 71 | + |
| 72 | +#### `dbos postgres start` |
| 73 | +Start a local Postgres database container with pgvector extension. |
| 74 | + |
| 75 | +**Options:** |
| 76 | +- `-c, --container-name` - Docker container name, defaults to dbos-db |
| 77 | +- `-i, --image-name` - Docker image name, defaults to pgvector/pgvector:pg16 |
| 78 | + |
| 79 | +**Usage:** |
| 80 | +```bash |
| 81 | +java -jar dbos.jar postgres start |
| 82 | +``` |
| 83 | + |
| 84 | +Creates a PostgreSQL container with: |
| 85 | +- Container name: `dbos-db` (unless overridden by `--container-name`) |
| 86 | +- Port: 5432 |
| 87 | +- Default database: `dbos` |
| 88 | +- Default user: `postgres` |
| 89 | +- Default password: `dbos` |
| 90 | + |
| 91 | +#### `dbos postgres stop` |
| 92 | +Stop the local Postgres database container. |
| 93 | + |
| 94 | +**Usage:** |
| 95 | +```bash |
| 96 | +java -jar dbos.jar postgres stop |
| 97 | +``` |
| 98 | +**Options:** |
| 99 | +- `-c, --container-name` - Docker container name, defaults to dbos-db |
| 100 | + |
| 101 | +### `dbos workflow` |
| 102 | +Manage DBOS workflows. |
| 103 | + |
| 104 | +#### `dbos workflow list` |
| 105 | +List workflows for your application. |
| 106 | + |
| 107 | +**Options:** |
| 108 | +- `-l, --limit <number>` - Limit the results returned (default: 10) |
| 109 | +- `-o, --offset <number>` - Offset for pagination |
| 110 | +- `-S, --status <status>` - Filter by status (PENDING, SUCCESS, ERROR, ENQUEUED, CANCELLED, or MAX_RECOVERY_ATTEMPTS_EXCEEDED) |
| 111 | +- `-n, --name <name>` - Retrieve workflows with this name |
| 112 | +- `-v, --application-version <version>` - Retrieve workflows with this application version |
| 113 | +- `-s, --start-time <timestamp>` - Retrieve workflows starting after this timestamp (ISO 8601) |
| 114 | +- `-e, --end-time <timestamp>` - Retrieve workflows starting before this timestamp (ISO 8601) |
| 115 | +- `-q, --queue <queue>` - Retrieve workflows on this queue |
| 116 | +- `-Q, --queues-only` - Retrieve only queued workflows |
| 117 | +- `-d, --sort-desc` - Sort the results in descending order (older first) |
| 118 | + |
| 119 | +**Usage:** |
| 120 | +```bash |
| 121 | +java -jar dbos.jar workflow list |
| 122 | +java -jar dbos.jar workflow list --limit 50 --status SUCCESS |
| 123 | +java -jar dbos.jar workflow list --name "ProcessOrder" |
| 124 | +``` |
| 125 | + |
| 126 | +#### `dbos workflow get [workflow-id]` |
| 127 | +Retrieve the status of a specific workflow. |
| 128 | + |
| 129 | +**Usage:** |
| 130 | +```bash |
| 131 | +java -jar dbos.jar workflow get abc123def456 |
| 132 | +``` |
| 133 | + |
| 134 | +Returns detailed information about the workflow including its status, start time, end time, and other metadata. |
| 135 | + |
| 136 | +#### `dbos workflow steps [workflow-id]` |
| 137 | +List the steps of a workflow. |
| 138 | + |
| 139 | +**Usage:** |
| 140 | +```bash |
| 141 | +java -jar dbos.jar workflow steps abc123def456 |
| 142 | +``` |
| 143 | + |
| 144 | +Shows all the steps executed within a workflow, their status, and execution details. |
| 145 | + |
| 146 | +#### `dbos workflow cancel [workflow-id]` |
| 147 | +Cancel a workflow so it is no longer automatically retried or restarted. |
| 148 | + |
| 149 | +**Usage:** |
| 150 | +```bash |
| 151 | +java -jar dbos.jar workflow cancel abc123def456 |
| 152 | +``` |
| 153 | + |
| 154 | +#### `dbos workflow resume [workflow-id]` |
| 155 | +Resume a workflow that has been cancelled. |
| 156 | + |
| 157 | +**Usage:** |
| 158 | +```bash |
| 159 | +java -jar dbos.jar workflow resume abc123def456 |
| 160 | +``` |
| 161 | + |
| 162 | +#### `dbos workflow fork [workflow-id]` |
| 163 | +Fork a workflow from the beginning or from a specific step. |
| 164 | + |
| 165 | +**Options:** |
| 166 | +- `-s, --step <number>` - Restart from this step (default: 1) |
| 167 | +- `-f, --forked-workflow-id <id>` - Custom workflow ID for the forked workflow |
| 168 | +- `-a, --application-version <version>` - Application version for the forked workflow |
| 169 | + |
| 170 | +**Usage:** |
| 171 | +```bash |
| 172 | +java -jar dbos.jar workflow fork abc123def456 |
| 173 | +java -jar dbos.jar workflow fork abc123def456 --step 3 |
| 174 | +java -jar dbos.jar workflow fork abc123def456 --forked-workflow-id custom-id-123 |
| 175 | +``` |
| 176 | + |
| 177 | +### `dbos version` |
| 178 | +Show the version and exit. |
| 179 | + |
| 180 | +**Usage:** |
| 181 | +```bash |
| 182 | +java -jar dbos.jar --version |
| 183 | +``` |
| 184 | + |
| 185 | +## License |
| 186 | + |
| 187 | +See the main project [LICENSE](https://github.com/dbos-inc/dbos-transact-java/blob/main/LICENSE) file for details. |
0 commit comments