aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/pushgateway/files/pushgateway.in
blob: d61b5975fa1e14322ea50d7b28c8ef44dc849295 (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD$

# PROVIDE: pushgateway
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# pushgateway_enable (bool, default: "NO"):
#	Set it to YES to enable pushgateway.
# pushgateway_user (string, default: "prometheus"):
#	Set user to run pushgateway.
# pushgateway_group (string, default: "prometheus"):
#	Set group to run pushgateway.
# pushgateway_data_dir (string, default: "/var/db/pushgateway"):
#	Set directory to run pushgateway in.
# pushgateway_persistence_file (string, default: "${pushgateway_data_dir}/persistent.data")
#	Set file in which the pushed metrics will be persisted.
# pushgateway_log_file (string, default: "/var/log/pushgateway.log")
#	Set file that pushgateway will log to.
# pushgateway_args (string, default: ""):
#	Set additional command line arguments.

. /etc/rc.subr

name=pushgateway
rcvar=pushgateway_enable

load_rc_config "$name"

: ${pushgateway_enable:=NO}
: ${pushgateway_user:=prometheus}
: ${pushgateway_group:=prometheus}
: ${pushgateway_data_dir:=/var/db/pushgateway}
: ${pushgateway_persistence_file:=${pushgateway_data_dir}/persistent.data}
: ${pushgateway_log_file:=/var/log/pushgateway.log}

pidfile=/var/run/pushgateway.pid
command=/usr/sbin/daemon
procname="%%PREFIX%%/bin/pushgateway"
sig_reload=HUP
extra_commands=reload
command_args="-p ${pidfile} /usr/bin/env ${procname} \
				--persistence.file=${pushgateway_persistence_file} \
				${pushgateway_args} > ${pushgateway_log_file} 2>&1"
start_precmd=pushgateway_startprecmd

pushgateway_startprecmd()
{
	if [ ! -e "${pidfile}" ]; then
		install -o ${pushgateway_user} -g ${pushgateway_group} /dev/null ${pidfile}
	fi
	if [ ! -f "${pushgateway_log_file}" ]; then
		install -o ${pushgateway_user} -g ${pushgateway_group} -m 640 /dev/null ${pushgateway_log_file}
	fi
	if [ ! -d ${pushgateway_data_dir} ]; then
		install -d -o ${pushgateway_user} -g ${pushgateway_group} -m 750 ${pushgateway_data_dir}
	fi
}

run_rc_command "$1"