|
root / examples / daemon-with-restart / service.toml
service.toml TOML 33 lines 1.0 KB
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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