|
root / examples / with-stop-script
with-stop-script Plain Text 27 lines 820 B
 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
# Example: daemon with a companion stop script.
#
# Some services need an explicit shutdown sequence rather than just
# being signaled. The [exec].stop field references a script in the
# same directory. zyginit runs it with a stop timeout (default 60s)
# before falling back to SIGKILL.

[service]
type = "daemon"
description = "Database daemon with graceful shutdown"

[exec]
start = "./start.sh"
stop = "./stop.sh"
user = "dbuser"

[stop]
# How long zyginit waits for stop.sh to finish before escalating
# to SIGKILL. Default is 60 seconds.
timeout = 30
#!/bin/sh
# Start the database, foregrounded so zyginit can supervise it directly.
exec /usr/sbin/example-dbd --foreground --config /etc/example-db.conf
#!/bin/sh
# Graceful shutdown: tell the daemon to flush and exit cleanly.
exec example-dbctl --shutdown --wait