blob: abba9f865345dc104af1796fdfb3aeab9e394b4e (
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
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="checkconfig"
extra_started_commands="reload"
command="/usr/bin/haproxy"
pidfile="${HAPROXY_PIDFILE:-/run/${SVCNAME}.pid}"
configs=
if [ -z "${CONFIGS}" ]; then
if [ -f "/etc/haproxy/${SVCNAME}.cfg" ]; then
CONFIGS=/etc/haproxy/${SVCNAME}.cfg
elif [ -f "/etc/${SVCNAME}.cfg" ]; then
CONFIGS=/etc/${SVCNAME}.cfg # Deprecated
fi
fi
for conf in $CONFIGS; do
configs="${configs} -f ${conf}"
done
command_args="-D -p ${pidfile} ${configs} ${HAPROXY_OPTS}"
depend() {
need net
use dns logger
}
checkconfig() {
if [ -z "${CONFIGS}" ]; then
eerror "No config(s) has been specified"
return 1
fi
for conf in $CONFIGS; do
if [ ! -f "${conf}" ]; then
eerror "${conf} does not exist!"
return 1
fi
done
ebegin "Checking ${CONFIGS}"
$command -q -c $configs $HAPROXY_OPTS
eend $?
}
start_pre() {
if [ "${RC_CMD}" != "restart" ]; then
checkconfig || return 1
fi
}
stop_pre() {
if [ "${RC_CMD}" = "restart" ]; then
checkconfig || return 1
fi
}
stop() {
local _t _pid
_t="$(mktemp)"
for _pid in $(cat ${pidfile}) ; do
echo "${_pid}" > "${_t}"
pidfile="${_t}" openrc_default_stop
done
rm -f "${_t}"
}
reload() {
checkconfig || { eerror "Reloading failed, please fix your config(s) first"; return 1; }
if [ "$(command -v reload_seamless)" = "reload_seamless" ]; then
einfo "Calling user-defined reload_seamless()"
reload_seamless || { eerror "reload_seamless() failed!"; return 1; }
fi
ebegin "Reloading ${SVCNAME}"
$command -D -p "${pidfile}" $configs $HAPROXY_OPTS -sf $(cat "${pidfile}")
eend $?
}
|