summaryrefslogtreecommitdiff
path: root/databases/py-carbon/files/carbon-aggregator.sh
blob: 386c90e60693c5ca6cd7bc207d51d082e0a4f62d (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: carbon-aggregator.sh,v 1.1 2015/12/11 21:40:50 riz Exp $
#
# PROVIDE: carbon-aggregator
# REQUIRE: DAEMON
# KEYWORD: shutdown

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
fi

name="carbon_aggregator"
rcvar=$name
command="@PREFIX@/bin/carbon-aggregator.py"
config="--config=@PKG_SYSCONFDIR@/carbon.conf"
graphite_user="@GRAPHITE_USER@"
graphite_group="@GRAPHITE_GROUP@"
graphite_dir="@GRAPHITE_DIR@"
extra_commands="status"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
start_precmd='setproclimits'

setproclimits()
{
	local climit
	climit=$(ulimit -n)
	if [ "$climit" -lt 4096 ]; then
		ulimit -n 4096
	fi
}

carbon_aggregator_start()
{
	@SU@ -m ${graphite_user} -c "${command} ${config}  start"
}

carbon_aggregator_stop()
{
	@SU@ -m ${graphite_user} -c "${command} ${config} stop"
}

carbon_aggregator_status()
{
	@SU@ -m ${graphite_user} -c "${command} ${config} status"
}


if [ -f /etc/rc.subr -a -f /etc/rc.conf ]; then
	load_rc_config $name
	run_rc_command "$1"
else
	if [ -f /etc/rc.conf ]; then
		. /etc/rc.conf
	fi
	case $1 in
	start)
		${start_cmd}
		;;
	stop)
		${stop_cmd}
		;;
	restart)
		${stop_cmd} && ${start_cmd}
		;;
	*)
		@ECHO@ "Usage: $0 {start|stop|restart}" 1>&2
		exit 64
		;;
	esac
fi