# Example: long-running daemon with restart-on-failure.
#
# This is the bread-and-butter pattern: a daemon that should run
# forever, restart if it crashes, and run as an unprivileged user.

[service]
type = "daemon"
description = "Example HTTP server (long-running daemon)"

[exec]
start = "/usr/sbin/example-httpd"

# Run as the 'webuser' account, in /var/lib/example as the cwd.
user = "webuser"
working_directory = "/var/lib/example"

# Pass environment to the child. Each entry is "KEY=value".
environment = ["LANG=C", "EXAMPLE_LOG_LEVEL=info"]

[restart]
# Restart automatically when the process exits with non-zero status.
# Options: "always" (restart on any exit), "failure" (default; only on
# non-zero exit), "never" (don't restart).
on = "failure"

# Wait 5 seconds between restart attempts (back-off would be a future feature).
delay = 5

# Give up after 5 failed restart attempts in a row. The service then
# transitions to STATE_MAINTENANCE and zygctl reports "failed". Set to
# -1 for unlimited.
max_retries = 5
