devbox service to run long-lived commands, such as dev servers, as services on a Devbox. A service starts when you create it and again every time the Devbox boots. The Devbox restarts it after failures and retains its logs.
Every subcommand takes the Devbox and the service as optional positional arguments. On a terminal, omitting either opens a picker. The service picker lists only services you created. Without a terminal, pass both arguments explicitly.
Usage
Options
boolean
default:"false"
Include Devboxes owned by other workspace members in the Devbox picker. Every
devbox service subcommand accepts this option.devbox service create
Create a service that starts now and on each boot, and restarts after failures. Pass the command after --. It runs without a shell, so wrap shell features such as && and pipes in sh -c '...'. If you omit the name or the command, the CLI prompts for them, and it also prompts for the working directory.
The command runs in the Devbox’s default directory. Relative --cwd paths start there.
On a terminal, the CLI prints the service details and then streams its logs for five seconds, so you can see whether it started cleanly. The command fails if the service was created but could not start.
Usage
Create a dev server
Use shell features
Options
string
Run the command in this directory. Relative paths start at the Devbox’s default directory.
int
default:"5"
Stream logs for this many seconds after creating the service.
string
Name the service. Names must be unique on the Devbox. The CLI prompts for a name if you omit it.
boolean
default:"false"
Skip log streaming after creating the service.
devbox service list
List the services on a Devbox. The default table shows each service’s name, status, and command, plus its ports when any service has them. Status is starting, running, restarting, failed, stopping, stopped, or not started.
Usage
List services as JSON
services array. Each entry has the same fields as devbox service describe --output json.
Options
string
default:"text"
Set the output format to
text or json.devbox service describe
Show a service’s configuration, current status, and how to reach it. The output ends with the commands to open its ports, start it if it is stopped, and stream its logs.
Usage
Describe a service
Output
Status includes the last exit code and the restart count. When a service is stopped, the output shows the devbox service start command that brings it back.
Describe a service as JSON
Output
ports is included when the service has ports. process.last_exit is included after the service has exited at least once.
Options
string
default:"text"
Set the output format to
text or json.devbox service logs
Replay the output retained for a service’s latest run, then follow new output. Following ends when that run exits. It does not continue into the next run after a restart.
Usage
Read the retained logs
Options
boolean
default:"false"
Return after printing the retained logs instead of following new output.
devbox service stop
Stop a service until you start it again. A stopped service does not start when the Devbox boots, and its ports are closed. By default, the service receives SIGTERM and is killed if it has not exited after 15 seconds.
Usage
Stop a service
Output
Options
boolean
default:"false"
Kill the service immediately instead of letting it shut down gracefully.
devbox service start
Start a stopped service. The service starts again on each boot.
Usage
Start a service
devbox service delete
Stop a service and permanently remove it, together with its ports. The CLI asks for confirmation. Without a terminal, pass --force.
Usage
Delete without confirmation
Output
Options
boolean
default:"false"
Skip the confirmation prompt.
Related topics
Devbox Services
Run dev servers and other long-lived processes on a Devbox.
devbox logs
Stream the output of detached executions.