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