aboutsummaryrefslogtreecommitdiffstats
path: root/testing/consul/consul.initd
blob: 15d8208823df343c5a4f84e98b6da003ecfe4c23 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/sbin/openrc-run
description="A tool for service discovery, monitoring and configuration"
description_checkconfig="Verify configuration files"
description_healthcheck="Check health status"
description_reload="Reload configuration"

extra_commands="checkconfig"
extra_started_commands="healthcheck reload"

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
}

checkconfig() {
	ebegin "Checking /etc/consul"
	$command validate /etc/consul
	eend $?
}

start_pre() {
	checkconfig
	checkpath -f -m 0640 -o "$command_user" "$output_log" "$error_log"
}

healthcheck() {
	$command config list -kind proxy-defaults
}

reload() {
	start_pre \
		&& ebegin "Reloading $RC_SVCNAME configuration" \
		&& supervise-daemon "$RC_SVCNAME" --signal HUP --pidfile "$pidfile"
	eend $?
}