Lifecycle
How a node reacts to file changes, how it stops, how it restarts after exiting and when it starts at all:
const worker = defineService({
name: 'worker',
provision: { image: { context: './worker' } },
watch: { paths: ['./config'], ignore: ['**/*.log'], onChange: 'restart' },
stop: { signal: 'SIGTERM', grace: '10s', killGroup: true },
restart: { policy: 'always', delay: '1s', minUptime: '15s', backoff: 'exponential' },
start: 'manual',
});Watching files
watch is the exception, not the norm on a service. Vite, tsx watch and air already watch their own source, and restarting the process would destroy the hot-reload state those tools exist to preserve. Reach for it when a service cannot watch itself — a plain node server.js, or a compiled binary. Everyday development has a table of edit loops.
A node that should run only in reaction to edits pairs watch with start: 'onChange':
const image = defineService({
name: 'image',
provision: { image: { context: './api' } },
watch: { paths: ['./api/Dockerfile'], onChange: 'rebuild' },
start: 'onChange',
});Alzo uses one native recursive watcher for the configuration's directory. Bursts of editor saves are coalesced, each node reconciles at most once at a time, and edits that arrive during a build become one queued pass. A one-shot build or task runs again; a service restarts; provision.image.watch rebuilds the image and recreates its container. alzo ci stays one-shot and does not watch.
When the watcher loses events
If the operating system's file watcher reports dropped events, the history of changes is incomplete. Alzo attempts a bounded rescan of the source and records the gap in the activity history. When it cannot recover safely — an unsupported or unstable situation, or one involving a task — it refuses instead of guessing. After a refusal, run alzo down, wait for teardown to finish, then run alzo up for a fresh environment, remembering that down deletes named volumes that are not retained. alzo up alone may attach to the failed environment's supervisor, the owner that alzo up started, and alzo reload does not repair its watcher.
Stopping
stop decides how a process ends. killGroup: true is the default, because a dev server that is not killed with its whole process group leaks a child process per run.
Restarting
restart keys the delay on uptime: a process that ran a while and then exited hit something transient and comes back after delay; one that exited sooner than minUptime failed during startup and backs off instead. backoff: 'exponential' stops at 5m; maxDelay moves that ceiling rather than creating it, so the example above is bounded even though it omits one. No duration anywhere may exceed 24.8 days, because that is what a timer can express.
Restarting a node never restarts its dependents automatically; restartOn declares when one should, and alzo restart ...api cascades by hand.
Starting
start has three values:
'auto', the default, starts the node withalzo up.'manual'keeps a node in the graph — named, ordered, visible — without running it until you ask, withalzo start,alzo runor a targetedalzo up.'onChange'starts it only when itswatchpaths change, which is how a node that exists to react to edits stays out of the way on a cold start.
One start setting covers what other tools spread across several, such as Tilt's auto_init, trigger_mode and a separate enabled state, whose interaction is a well-documented source of confusion.