blob: 73db4dd8b3c8b17577215c764c590fc457e3fcb7 (
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
|
#!/sbin/openrc-run
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_started_commands="reload"
CONFIGFILE="/etc/pgpool2/pgpool.conf"
LOGFILE="/var/log/pgpool2.log"
depend() {
use net
use postgresql
after logger
}
get_config() {
[ -f ${CONFIGFILE} ] || return 1
eval echo $(sed -e 's:#.*::' ${CONFIGFILE} | \
awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
}
PIDFILE="$(get_config pid_file_name)"
: ${PIDFILE:='/run/pgpool/pgpool.pid'}
start_pre() {
# $logdir contains status file(s), not log files.
local logdir=$(get_config logdir)
local socket_dir=$(get_config socket_dir)
local pcp_socket_dir=$(get_config pcp_socket_dir)
checkpath -o pgpool:postgres -m 0770 -d $(dirname ${PIDFILE}) || return 1
checkpath -o pgpool:postgres -m 0770 -d ${logdir:-'/var/lib/pgpool'} || return 1
checkpath -o pgpool:postgres -m 0660 -f ${LOGFILE} || return 1
checkpath -o root:postgres -m 1775 \
-d ${socket_dir:-'/run/postgresql'} || return 1
checkpath -o pgpool:postgres -m 0770 \
-d ${pcp_socket_dir:-'/run/postgresql/pgpool'} || return 1
}
start() {
ebegin "Starting pgpool2"
start-stop-daemon --start \
--user pgpool:postgres \
--pidfile ${PIDFILE} \
--exec /usr/bin/pgpool
eend
}
stop() {
local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
ebegin "Stopping pgpool (this can take up to ${seconds} seconds)"
local retval
local retries=SIGTERM/${NICE_TIMEOUT}
if [ "${RUDE_QUIT}" != "NO" ] ; then
einfo "RUDE_QUIT enabled."
retries="${retries}/SIGINT/${RUDE_TIMEOUT}"
fi
if [ "${FORCE_QUIT}" = "YES" ] ; then
einfo "FORCE_QUIT enabled."
ewarn "A recover-run might be executed on next startup."
retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}"
fi
# Loops through nice, rude, and force quit in one go.
start-stop-daemon --stop \
--pidfile ${PIDFILE} \
--retry ${retries}
eend
}
reload() {
start-stop-daemon --signal HUP \
--pidfile ${PIDFILE}
}
|