Background daemons
Start and stop a background daemon with the rest of your stack, even when it detaches from the command that launched it. Daemon mode gives devhost explicit start, stop, and optional status commands for services it cannot supervise as foreground children.
Configure a daemon
Section titled “Configure a daemon”[services.mailpit]port = 8025host = "mail-hello"health = { http = "http://127.0.0.1:8025/api/v1/info" }
[services.mailpit.lifecycle]mode = "daemon"start = ["./scripts/mailpit-devctl", "start"]status = ["./scripts/mailpit-devctl", "status"]stop = ["./scripts/mailpit-devctl", "stop"]When the stack starts, devhost runs status first. If it exits 0, the daemon is already running and devhost skips start; otherwise it runs start. Either way, devhost then waits for the health check and adds the routes. On shutdown and on every restart it runs stop.
A daemon can keep its launcher’s stdout and stderr open: startup continues when the launcher exits, and daemon logs remain visible until the service stops. Interrupting startup sends the running lifecycle helper a termination signal, escalating to a kill after the shutdown grace period if it ignores termination. If startup fails and its cleanup also fails, devhost reports both errors and retries the daemon’s cleanup when the stack shuts down.
startandstopare required;statusis optional.- A daemon service has no top-level
command, and stays managed (nomanaged = false). - It needs a fixed
portor an explicit health check:port = "auto"andhealth.processare not allowed, because devhost owns no long-lived process for it. - Its recovery page reports the health check, not a process exit.