summaryrefslogtreecommitdiff
blob: c4fbee5331a06d4769059b2766724a07383abf08 (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
#!/sbin/openrc-run
# Copyright 1999-2023 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

description="Graphite whisper metrics renderer."

carbonapi_config=${CONFIG_FILE:-/etc/carbonapi/${SVCNAME}.yaml}

command="/usr/bin/carbonapi"
command_args="-config ${carbonapi_config}"
pidfile="/run/carbonapi/${SVCNAME}.pid"
user=${USER:-carbon}
group=${GROUP:-carbon}

depend() {
	need net
	use dns
}

start_pre() {
	mkdir -p "${pidfile%/*}"
	mkdir -p /var/log/carbonapi
	chown ${user}:${group} "${pidfile%/*}" /var/log/carbonapi
}

stop_post() {
	rm -f "${pidfile}"
}

start() {
	ebegin "Starting ${SVCNAME}"
	start-stop-daemon --start --pidfile "${pidfile}" \
		--make-pidfile --background \
		--user ${user} --group ${group} \
		--exec ${command} -- \
		${command_args}
	eend $?
}

stop() {
	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --exec ${command} --pidfile "${pidfile}"
	eend $?
}