Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# PROVIDE: prometheus |
4 |
# REQUIRE: LOGIN |
5 |
# KEYWORD: shutdown |
6 |
# |
7 |
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf |
8 |
# to enable this service: |
9 |
# |
10 |
# prometheus_enable (bool): Set to NO by default |
11 |
# Set it to YES to enable prometheus |
12 |
# prometheus_user (string): Set user to run prometheus |
13 |
# Default is "prometheus" |
14 |
# prometheus_group (string): Set group to run prometheus |
15 |
# Default is "prometheus" |
16 |
# prometheus_data_dir (string): Set dir to run prometheus in |
17 |
# Default is "/var/tmp/prometheus" |
18 |
# prometheus_log_file (string): Set file that prometheus will log to |
19 |
# Default is "/var/log/prometheus.log" |
20 |
# prometheus_args (string): Set additional command line arguments |
21 |
# Default is "" |
22 |
|
23 |
. /etc/rc.subr |
24 |
|
25 |
name=prometheus |
26 |
rcvar=prometheus_enable |
27 |
|
28 |
load_rc_config $name |
29 |
|
30 |
: ${prometheus_enable:="NO"} |
31 |
: ${prometheus_user:="prometheus"} |
32 |
: ${prometheus_group:="prometheus"} |
33 |
: ${prometheus_config:="%%PREFIX%%/etc/prometheus.yml"} |
34 |
: ${prometheus_data_dir:="/var/db/prometheus"} |
35 |
: ${prometheus_log_file:="/var/log/prometheus.log"} |
36 |
: ${prometheus_args:=""} |
37 |
|
38 |
pidfile=/var/run/prometheus.pid |
39 |
required_files="${prometheus_config}" |
40 |
command="/usr/sbin/daemon" |
41 |
procname="%%PREFIX%%/bin/prometheus" |
42 |
sig_reload=HUP |
43 |
extra_commands="reload" |
44 |
command_args="-p ${pidfile} /usr/bin/env ${procname} \ |
45 |
-config.file=${prometheus_config} \ |
46 |
-storage.local.path=${prometheus_data_dir} \ |
47 |
${prometheus_args} > ${prometheus_log_file} 2>&1" |
48 |
|
49 |
start_precmd=prometheus_startprecmd |
50 |
|
51 |
prometheus_startprecmd() |
52 |
{ |
53 |
if [ ! -e ${pidfile} ]; then |
54 |
install -o ${prometheus_user} -g ${prometheus_group} /dev/null ${pidfile}; |
55 |
fi |
56 |
if [ ! -f "${prometheus_log_file}" ]; then |
57 |
install -o ${prometheus_user} -g ${prometheus_group} -m 640 /dev/null ${prometheus_log_file}; |
58 |
fi |
59 |
if [ ! -d ${prometheus_data_dir} ]; then |
60 |
install -d -o ${prometheus_user} -g ${prometheus_group} -m 750 ${prometheus_data_dir} |
61 |
fi |
62 |
} |
63 |
|
64 |
load_rc_config $name |
65 |
run_rc_command "$1" |