summaryrefslogtreecommitdiff
blob: 24d7889e783ff6f026b9751f4848c710abd0cd55 (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
#!/sbin/runscript
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

pidfile=${pidfile:-"/run/${SVCNAME}.pid"}

command="/usr/bin/consul"
command_args="agent ${command_args} -pid-file ${pidfile}"
command_background="true"
start_stop_daemon_args="--stdout /var/log/consul/${SVCNAME}.log"

description="tool for service discovery, monitoring and configuration."
extra_started_commands="reload telemetry"

depend() {
	need hostname
	use net
}

stop() {
	# We need to override the default stop function
	# because it uses SIGTERM whereas consul needs a SIGINT
	# to shutdown gracefully
    ebegin "Stopping ${SVCNAME}"
    start-stop-daemon --signal SIGINT --pidfile "${pidfile}"
    eend $?
}

reload() {
	ebegin "Reloading ${SVCNAME}"
	start-stop-daemon --signal SIGHUP --pidfile "${pidfile}"
	eend $?
}

telemetry() {
    ebegin "Logging telemetry for ${SVCNAME}"
    start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}"
    eend $?
}