|
root / examples / task-with-condition
task-with-condition Plain Text 30 lines 1.1 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
# Example: task with a runtime condition.
#
# A 'task' may run for any duration but is expected to eventually
# exit cleanly. Unlike 'oneshot', tasks aren't expected to exit
# immediately. Unlike 'daemon', tasks never restart.
#
# The [condition] block declares pre-flight checks. If any condition
# fails at startup, the service enters STATE_SKIPPED without forking —
# no failure, no restart loop. Useful for platform probes.

[service]
type = "task"
description = "ACPI hotplug daemon (skipped on platforms without ACPI)"

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

[condition]
# This file must exist for the service to start. If missing, the
# service is SKIPPED with reason "missing /dev/acpi".
exists_file = "/dev/acpi"

# Alternative form: at least one of these paths must exist (OR semantics
# across the list, AND with other condition keys).
# exists_file_any = ["/dev/acpi", "/dev/acpihp"]

# A command that must exit 0 (5-second timeout). Useful for richer
# probes than file existence — e.g., checking a hardware flag.
# command = "/usr/sbin/example-acpihpd --probe"