aboutsummaryrefslogtreecommitdiffstats
path: root/testing/consul/consul.initd
diff options
context:
space:
mode:
Diffstat (limited to 'testing/consul/consul.initd')
-rw-r--r--testing/consul/consul.initd62
1 files changed, 33 insertions, 29 deletions
diff --git a/testing/consul/consul.initd b/testing/consul/consul.initd
index ef3adf1803..bb1a13300c 100644
--- a/testing/consul/consul.initd
+++ b/testing/consul/consul.initd
@@ -1,44 +1,48 @@
#!/sbin/openrc-run
-CONSUL_LOG_FILE="/var/log/${SVCNAME}.log"
-
-name=consul
description="A tool for service discovery, monitoring and configuration"
-description_checkconfig="Verify configuration file"
-daemon=/usr/sbin/$name
-daemon_user=$name
-daemon_group=$name
+description_checkconfig="Verify configuration files"
+description_healthcheck="Check health status"
+description_reload="Reload configuration"
+
extra_commands="checkconfig"
+extra_started_commands="healthcheck reload"
-start_pre() {
- checkpath -f -m 0644 -o ${SVCNAME}:${SVCNAME} "$CONSUL_LOG_FILE"
-}
+command="/usr/sbin/$RC_SVCNAME"
+command_args="$consul_opts"
+command_user="$RC_SVCNAME:$RC_SVCNAME"
+
+supervisor=supervise-daemon
+pidfile="/run/$RC_SVCNAME.pid"
+output_log="/var/log/$RC_SVCNAME.log"
+error_log="/var/log/$RC_SVCNAME.log"
+umask=027
+respawn_max=0
+respawn_delay=10
+healthcheck_timer=60
depend() {
- need net
- after firewall
+ need net
+ after firewall
}
checkconfig() {
- consul validate /etc/consul
+ ebegin "Checking /etc/consul"
+ consul validate /etc/consul
+ eend $?
}
-start() {
- checkconfig || return 1
-
- ebegin "Starting ${name}"
- start-stop-daemon --start --quiet \
- -m --pidfile /var/run/${name}.pid \
- --user ${daemon_user} --group ${daemon_group} \
- -b --stdout $CONSUL_LOG_FILE --stderr $CONSUL_LOG_FILE \
- -k 027 --exec ${daemon} -- ${consul_opts}
- eend $?
+start_pre() {
+ checkconfig
+ checkpath -f -m 0640 -o "$command_user" "$output_log" "$error_log"
}
-stop() {
- ebegin "Stopping ${name}"
- start-stop-daemon --stop --quiet \
- --pidfile /var/run/${name}.pid \
- --exec ${daemon}
- eend $?
+healthcheck() {
+ $command info > /dev/null 2>&1
}
+reload() {
+ start_pre \
+ && ebegin "Reloading $RC_SVCNAME configuration" \
+ && supervise-daemon "$RC_SVCNAME" --signal HUP --pidfile "$pidfile"
+ eend $?
+}