after: and before: control startup ordering. A service listed in another's after is started first; before is the same edge written from the other side. gopherd computes the order with a topological sort.
# Order startup with `after` and `before`: zeroth -> first -> second.
processes:
- name: second
command: /bin/sh
args: ["-c", "echo second >> ORDERLOG && sleep 300"]
after: [first]
on-failure: shutdown
- name: first
command: /bin/sh
args: ["-c", "echo first >> ORDERLOG && sleep 300"]
on-failure: shutdown
- name: zeroth
command: /bin/sh
args: ["-c", "echo zeroth >> ORDERLOG && sleep 300"]
before: [first]
on-failure: shutdownseconddeclaresafter: [first], so gopherd startsfirstfirst.zerothdeclaresbefore: [first]— the mirror form, useful when the inserted service is the one being added and the existing configs should stay untouched.- Declaration order in the file does not matter — the dependency graph does.
after/beforeorder startup only; userequiresif a dependency failure should also fail the dependent.
zerothstarts first, thenfirst, thensecond; the log readszeroth,first,second.
ORDERLOG is replaced with a temp path via RunConfig. The test asserts gopherd's started lines appear in zeroth, first, second order. Note after/before order gopherd's start calls; the echoes themselves run in separate shells, so use a ready-check when the dependent needs the dependency's work completed.
go test ./documentation/dependencies/ -v