blob: 03dd73c0aa88e391787b4b1594fd36dc7e97464d (
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
65
|
#!/bin/sh
# PROVIDE: prometheus
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# prometheus_enable (bool): Set to NO by default
# Set it to YES to enable prometheus
# prometheus_user (string): Set user to run prometheus
# Default is "prometheus"
# prometheus_group (string): Set group to run prometheus
# Default is "prometheus"
# prometheus_data_dir (string): Set dir to run prometheus in
# Default is "/var/db/prometheus"
# prometheus_log_file (string): Set file that prometheus will log to
# Default is "/var/log/prometheus.log"
# prometheus_args (string): Set additional command line arguments
# Default is ""
. /etc/rc.subr
name=prometheus
rcvar=prometheus_enable
load_rc_config $name
: ${prometheus_enable:="NO"}
: ${prometheus_user:="prometheus"}
: ${prometheus_group:="prometheus"}
: ${prometheus_config:="%%PREFIX%%/etc/prometheus.yml"}
: ${prometheus_data_dir:="/var/db/prometheus"}
: ${prometheus_log_file:="/var/log/prometheus.log"}
: ${prometheus_args:=""}
pidfile=/var/run/prometheus.pid
required_files="${prometheus_config}"
command="/usr/sbin/daemon"
procname="%%PREFIX%%/bin/prometheus"
sig_reload=HUP
extra_commands="reload"
command_args="-p ${pidfile} /usr/bin/env ${procname} \
-config.file=${prometheus_config} \
-storage.local.path=${prometheus_data_dir} \
${prometheus_args} >> ${prometheus_log_file} 2>&1"
start_precmd=prometheus_startprecmd
prometheus_startprecmd()
{
if [ ! -e ${pidfile} ]; then
install -o ${prometheus_user} -g ${prometheus_group} /dev/null ${pidfile};
fi
if [ ! -f "${prometheus_log_file}" ]; then
install -o ${prometheus_user} -g ${prometheus_group} -m 640 /dev/null ${prometheus_log_file};
fi
if [ ! -d ${prometheus_data_dir} ]; then
install -d -o ${prometheus_user} -g ${prometheus_group} -m 750 ${prometheus_data_dir}
fi
}
load_rc_config $name
run_rc_command "$1"
|