Service operations commands
The service operations commands let an operator inspect and change the runtime state of services behind Kamal Proxy. Service actions use the running proxy's local control socket, so changes take effect in live routing and are saved for the next proxy start.
Operations model
Control path
The kamal-proxy command starts the proxy with run and uses the same command tree for later service actions. Commands other than run connect to the proxy's local control socket and ask it to change or report service state. The socket path comes from KAMAL_PROXY_SOCKET; without that setting, the proxy uses its runtime directory. internal/…/root.go• L13-35 internal/…/util.go• L14-21 internal/…/config.go• L30-35
The proxy restores saved service state when it starts. Operations that change a service also save a state snapshot, which makes service state survive a proxy restart. internal/…/run.go• L40-58 internal/…/router.go• L104-133 internal/…/router.go• L209-307
flowchart LR
Operator[Operator] --> CLI[kamal-proxy command]
CLI --> Socket[Local control socket]
Socket --> Proxy[Running proxy]
Proxy --> Live[Live service state]
Proxy --> State[Saved service state]
State --> Proxy
References: internal/…/root.go• L13-35 internal/…/util.go• L14-21 internal/…/run.go• L40-58 internal/…/config.go• L30-35 internal/…/router.go• L104-133 internal/…/router.go• L209-307
Service state
A service is a named routing entry with active targets and an optional rollout target group. Its operational state is one of running, paused, or stopped. A target is an upstream application endpoint; a read target can serve eligible read traffic but is not the write target shown by the service model. The list command exposes these states together with routing hosts, paths, TLS use, and rollout status. internal/…/router.go• L56-86 internal/…/service.go• L342-373
The main service actions are separate from rollout actions. pause and stop control whether requests may proceed. remove deletes the service from the registry. Rollout commands manage a second target group without changing the active group until traffic is assigned to it. See Operator command-line interface for the command hierarchy, Services and upstream targets for the target lifecycle, and Traffic pause and rollout controls for request behavior.
References: internal/…/router.go• L56-86 internal/…/service.go• L342-373 internal/…/pause_controller.go• L9-27 internal/…/service.go• L448-481
Service commands
Proxy process startup
kamal-proxy run starts the proxy process, restores the last saved service state, and waits for an interrupt or termination signal. It does not operate on one named service; it provides the running control and traffic process that the other commands need. internal/…/run.go• L20-58
The command accepts process-wide listener and timeout settings such as --http-port, --https-port, and --metrics-port. These settings affect the proxy process rather than an individual service. internal/…/run.go• L28-35
References: internal/…/run.go• L20-58 internal/…/router.go• L104-133
Service listing
kamal-proxy list shows services that have an active target group. The table reports the service name, host and path bindings, targets, state, TLS setting, and whether rollout traffic is enabled. Use kamal-proxy list --json when another tool needs the service descriptions rather than a display table. internal/…/list.go• L20-30 internal/…/list.go• L53-81
The list is a view of active services, not a history of removed services. It includes rollout target and split data in JSON, while the table gives a compact rollout-enabled value. internal/…/commands.go• L144-147 internal/…/router.go• L310-323
References: internal/…/list.go• L20-30 internal/…/list.go• L35-81 internal/…/commands.go• L144-147 internal/…/router.go• L310-323
Service pausing
kamal-proxy pause <service> temporarily stops normal request forwarding while keeping the service registered. Existing in-flight work is allowed to drain for --drain-timeout. New requests wait for up to --max-pause; requests that remain queued after that time are shed. internal/…/pause.go• L16-28 internal/…/service.go• L461-471
Pausing is useful for a short traffic hold. The service remains present and can return to normal operation with kamal-proxy resume <service>. Health checks continue to receive a successful response while the service is paused or stopped, so an upstream system does not remove the proxy from its own pool only because of this operator state. internal/…/resume.go• L16-24 internal/…/service.go• L642-665
References: internal/…/pause.go• L16-39 internal/…/resume.go• L16-36 internal/…/service.go• L461-481 internal/…/service.go• L642-665 internal/…/pause_controller.go• L84-130
Service stopping
kamal-proxy stop <service> puts the service into a stopped state and drains active and rollout target groups for --drain-timeout. New client requests receive an unavailable response with the optional --message text. The service stays registered until it is removed or deployed again. internal/…/stop.go• L16-28 internal/…/service.go• L448-459
Use stop when the service must remain known to the proxy but must not serve application traffic. Use remove instead when the service and its routing bindings must leave the registry. The distinction matters because removal cannot be undone by resume. internal/…/remove.go• L16-25 internal/…/router.go• L261-275
References: internal/…/stop.go• L16-39 internal/…/remove.go• L16-37 internal/…/service.go• L448-459 internal/…/router.go• L261-307
Service resuming
kamal-proxy resume <service> returns a paused or stopped service to the running state. Resuming changes the gate that controls new requests; it does not deploy new targets or change service routing settings. internal/…/resume.go• L16-36 internal/…/service.go• L474-481
References: internal/…/resume.go• L16-36 internal/…/router.go• L299-308 internal/…/service.go• L474-481
Service removal
kamal-proxy remove <service> deletes the named service from the routing registry and disposes its target groups. It is a structural cleanup action, not a traffic pause. The service must be deployed again before the proxy can route requests for it. internal/…/remove.go• L16-37 internal/…/router.go• L261-275
References: internal/…/remove.go• L16-37 internal/…/router.go• L261-275 internal/…/service_map.go• L40-50
Rollout commands
Rollout target deployment
kamal-proxy rollout deploy <service> places one or more new write targets and optional read targets into the service's rollout group. The proxy checks the new targets and drains any rollout group that they replace. This prepares a candidate without sending it normal traffic until rollout state enables and selects it. internal/…/rollout_deploy.go• L15-30 internal/…/router.go• L180-207
The rollout deployment command requires at least one --target. --read-target adds endpoints for read traffic. --deploy-timeout limits how long the new group may take to become healthy, while --drain-timeout limits cleanup of the replaced rollout group. The deployment workflow is described in Service deployment workflow.
References: internal/…/rollout_deploy.go• L15-41 internal/…/commands.go• L48-53 internal/…/router.go• L180-207 internal/…/router.go• L363-379
Rollout split configuration
kamal-proxy rollout set <service> defines which requests may use the rollout group. --percent selects a percentage of clients, while --list selects specific rollout values. The command requires one of these selectors. The split remains configured when rollout traffic is disabled, so an operator can prepare the rule before enabling it. internal/…/rollout_set.go• L15-29 internal/…/service.go• L258-269
The split uses the rollout cookie as the client value. An allowlisted value takes the rollout path, and other values use the configured percentage rule. Requests without that cookie stay on the active group. See Traffic pause and rollout controls for the request-level behavior.
References: internal/…/rollout_set.go• L15-39 internal/…/rollout_controller.go• L9-25 internal/…/rollout_controller.go• L40-77 internal/…/service.go• L527-535
Rollout state toggles
kamal-proxy rollout enable <service> activates the configured split, and kamal-proxy rollout disable <service> stops selecting the rollout group. Both commands require an existing rollout target group. Disabling the split does not remove that group or erase its configured percentage and allowlist. internal/…/rollout_enable.go• L15-34 internal/…/rollout_disable.go• L15-34 internal/…/service.go• L271-289
References: internal/…/rollout_enable.go• L15-34 internal/…/rollout_disable.go• L15-34 internal/…/service.go• L271-289 internal/…/rollout_controller.go• L40-55
Rollout target removal
kamal-proxy rollout remove <service> removes the rollout target group and clears its rollout state. It drains existing connections for up to --drain-timeout before disposal. The active target group remains in place, so this command is the rollback cleanup step after a rollout candidate is no longer needed. internal/…/rollout_remove.go• L15-26 internal/…/router.go• L242-258
References: internal/…/rollout_remove.go• L15-36 internal/…/service.go• L299-311 internal/…/router.go• L242-258
Operational sequence
Candidate rollout flow
The normal operator flow separates candidate preparation from traffic selection. This lets an operator verify a new target group before exposing it to the selected request set.
- Deploy the service's active target group with
deploy, or confirm the service withlist. - Add the candidate with
rollout deploy <service> --target .... - Set a percentage or allowlist with
rollout set. - Enable selection with
rollout enable. - Inspect the result with
list --jsonor the table view. - Disable selection and remove the candidate with
rollout disableandrollout removewhen the rollout ends.
flowchart LR
Active[Active targets] --> Deploy[rollout deploy]
Deploy --> Candidate[Rollout targets]
Candidate --> Split[rollout set]
Split --> Enable[rollout enable]
Enable --> Traffic[Selected traffic]
Traffic --> Disable[rollout disable]
Disable --> Remove[rollout remove]
Remove --> Active
This sequence is distinct from a full deploy, which replaces the active target group after health checks pass and drains the old group. See Service deployment workflow for that path.
References: internal/…/rollout.go• L9-22 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 internal/…/router.go• L151-207
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the Cobra command names, aliases, required arguments, and required rollout flags aligned with the control methods exposed by internal/…/commands.go.
- Keep
listtable columns and JSON fields aligned withServiceDescriptionandRolloutDescription; consumers may rely on both views. - Keep drain and pause timeout meaning aligned across the CLI argument types, service state changes, and target-group cleanup.
- Preserve state snapshots for every operation that changes service or rollout state so restart behavior remains consistent.
- Keep rollout target presence checks aligned with
rollout set,enable,disable, andremove; these commands require a candidate group.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The command cannot reach the control socket | No operation runs and the command returns the connection error | Start the proxy with run and use the same socket path for the operator command |
rollout set, enable, disable, or remove runs without rollout targets | The operation fails because no rollout target group exists | Run rollout deploy first |
A rollout candidate does not become healthy before --deploy-timeout | The candidate is rejected and the rollout operation fails | Check target health or increase the timeout only when the target needs more startup time |
A service is paused past --max-pause | Waiting requests are rejected instead of forwarded | Use resume when the hold ends or choose a suitable pause timeout |
| A service is removed while its name or host binding is still needed | The proxy no longer routes that service until a new deployment registers it | Use stop or pause for a temporary traffic change |
Key files
| File | Why to read it |
|---|---|
| internal/…/root.go | Shows the top-level command set and the boundary between process startup and service operations. |
| internal/…/list.go | Defines the operator's service status views in table and JSON form. |
| internal/…/pause.go, stop.go, resume.go, remove.go | Defines the day-two service state actions and their operator-facing controls. |
| internal/…/rollout.go and rollout_*.go | Defines the rollout target, split, enable, disable, and cleanup commands. |
| internal/…/commands.go | Shows how CLI requests map to the proxy control API. |
| internal/…/router.go | Shows the service-level effects and persistence boundary for each operation. |
| internal/…/service.go | Defines service state, active and rollout groups, and the request consequences of pause and stop. |
| internal/…/rollout_controller.go | Defines how configured rollout state selects requests. |
| internal/…/pause_controller.go | Defines running, paused, and stopped behavior. |