Operator command-line interface
The operator command-line interface manages a running Kamal Proxy process and the services that it routes. It starts the proxy, sends service changes through a local control API, and presents service state for humans or scripts.
Command model
The CLI uses one top-level command with separate commands for process control, deployment, service operations, rollout control, and version output. A service is the named proxy entry that connects request-matching rules to one or more upstream targets.
| Command group | Purpose |
|---|---|
run | Start the proxy and its control endpoint. |
deploy <service> | Register or replace the active targets for a service. |
rollout ... | Prepare and control a second target set for a progressive rollout. |
list or ls | Show active services and their current routing state. |
pause, resume, stop, remove | Change or remove a service after deployment. |
version | Print the CLI version without contacting the proxy. |
Process command
run is the process entry point. It restores saved service state, starts the HTTP proxy and its local control endpoint, then keeps the process alive until shutdown. The other operational commands are clients of this running process rather than separate proxy instances.
References: internal/…/run.go• L20-58 internal/…/server.go• L48-65 internal/…/server.go• L211-215
Deployment command
deploy <service> makes a target set available under a service name. Its flags describe the upstream targets and the service's request and health behavior, so deployment tooling can replace a live target set without stopping the proxy. The detailed deployment sequence is covered in Service deployment workflow.
References: internal/…/deploy.go• L18-70 internal/…/deploy.go• L77-107 internal/…/router.go• L151-177
Service operation commands
The day-two commands change the state of an existing service or remove it from the proxy. list reports active service descriptions, while pause, stop, resume, and remove apply traffic or lifecycle changes to one named service. See Service operations commands for the operational behavior of these commands.
References: internal/…/root.go• L23-31 internal/…/list.go• L20-50 internal/…/pause.go• L16-39 internal/…/stop.go• L16-39 internal/…/resume.go• L16-36 internal/…/remove.go• L16-37
Rollout command group
rollout manages a second target set and controls how traffic reaches it. Its subcommands deploy rollout targets, set a percentage or allowlist, enable or disable the split, and remove the rollout targets. These commands change traffic policy without changing the service's main routing identity; Traffic pause and rollout controls explains that policy at the proxy level.
References: internal/…/rollout.go• L9-21 internal/…/rollout_deploy.go• L15-41 internal/…/rollout_set.go• L15-39 internal/…/rollout_enable.go• L15-34 internal/…/rollout_disable.go• L15-34 internal/…/rollout_remove.go• L15-36
Proxy control API
The CLI and proxy are separate roles in one operating model. The CLI turns command arguments into control requests, and the running proxy applies those requests to its in-memory service registry and saves the resulting state when the operation changes service configuration.
Local control channel
Operational commands connect to a Unix domain socket. The socket path comes from KAMAL_PROXY_SOCKET or from the proxy's runtime directory, which keeps the control surface local to the host. The proxy registers a kamal-proxy RPC service on that socket and accepts one request per command.
References: internal/…/util.go• L14-21 internal/…/config.go• L30-35 internal/…/commands.go• L84-117
Command-to-router mapping
Each control request has a named API method and a typed argument set. The command handler does not own service behavior; it passes the request to the router, which applies deployment, lifecycle, or rollout changes to the service registry.
This diagram shows how an operator action moves from the CLI to live request routing.
flowchart LR
Operator[Operator or deployment tool] --> CLI[kamal-proxy command]
CLI --> Socket[Unix control socket]
Socket --> API[kamal-proxy RPC handler]
API --> Router[Proxy router]
Router --> Services[Service and target state]
Services --> Traffic[Live request routing]
References: internal/…/deploy.go• L84-87 internal/…/list.go• L35-49 internal/…/commands.go• L124-167 internal/…/router.go• L151-177
Control API operations
The control API exposes one method for each meaningful operator action. This keeps the CLI surface aligned with the proxy's service model rather than exposing internal routing steps.
| API method | Service concern |
|---|---|
Deploy | Active target set and service settings |
List | Active service descriptions |
Pause, Stop, Resume | Runtime service state |
Remove | Service registration removal |
RolloutDeploy | Rollout target set |
RolloutSet, RolloutEnable, RolloutDisable, RolloutRemove | Rollout policy and cleanup |
References: internal/…/commands.go• L19-76 internal/…/commands.go• L124-167
Service state and command output
The CLI reads and changes the proxy's service state through the same control boundary. This gives deployment automation a clear success or failure result while keeping live traffic decisions inside the proxy.
Service inventory
list is the main inspection command. Its table shows the service name, routing hosts and paths, targets, state, TLS status, and rollout status. The --json form exposes the same service descriptions for automation and other tools.
The service and target model behind this output is described in Services and upstream targets.
References: internal/…/list.go• L20-32 internal/…/list.go• L35-59 internal/…/list.go• L63-81 internal/…/router.go• L56-86 internal/…/router.go• L310-322
Command results
A command reports an error when the proxy cannot be reached or when the router rejects the requested change. Deployment commands also wait for the proxy's deployment checks unless the command explicitly requests a forced deployment, so a successful command represents an accepted change rather than only a parsed set of flags.
References: internal/…/deploy.go• L44-50 internal/…/deploy.go• L84-87 internal/…/router.go• L363-379 internal/…/router.go• L382-404
Change checklist
When these files or sections are changed, remember to consider these:
- Register every new top-level command in internal/…/root.go so the binary exposes it.
- Keep each CLI argument contract aligned across the command flags, the RPC argument type, the command handler, and the router method.
- Keep the socket path rules identical for the
runprocess and all client commands. - Update both table and JSON output when service description fields change.
- Preserve the distinction between active targets and rollout targets when changing rollout commands or API methods.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The proxy is not running or the CLI uses a different socket path. | The command cannot reach the control API. | Start run with the same socket setting used by the client. |
| A target does not become healthy within the deployment limit. | The new target set is rejected and the active service is not replaced. | Check target health or use deployment settings that match the service. |
| A service uses host settings that conflict with another service. | The deployment is rejected to avoid ambiguous routing. | Use unique host and path ownership. |
| An operation names a service that is not registered. | The router returns a service-not-found error. | Inspect list before applying a day-two or rollout command. |
| A buffer size flag is set without enabling the matching buffer. | The CLI rejects the command before it reaches the proxy. | Enable request or response buffering with its related size flags. |
Key files
| File | Why to read it |
|---|---|
| internal/…/root.go | Defines the top-level command hierarchy. |
| internal/…/deploy.go | Shows how deployment intent becomes a control request. |
| internal/…/rollout.go | Defines the rollout command group. |
| internal/…/util.go | Defines the CLI's local control connection and environment lookup. |
| internal/…/commands.go | Defines the control API and maps methods to router actions. |
| internal/…/router.go | Owns service changes and live routing state. |
| internal/…/server.go | Shows how the running proxy starts the control API beside its traffic listeners. |