blob: a1b956ea78e48b5331d0f4f24cca302a80f86d62 (
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
|
#!/sbin/openrc-run
extra_started_commands="reload"
extra_commands="configtest"
set_phpvars() {
PHPSLOT="${SVCNAME#php-fpm-}"
PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid"
if [ ${PHPSLOT} = 'php-fpm' ] ; then
PHPSLOT="$(eselect php show fpm)"
PHP_FPM_PID="/run/php-fpm.pid"
fi
PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf"
PHP_FPM_BIN="/usr/lib/${PHPSLOT}/bin/php-fpm"
}
start() {
ebegin "Starting PHP FastCGI Process Manager"
set_phpvars
start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \
--exec "${PHP_FPM_BIN}" \
-- \
--fpm-config "${PHP_FPM_CONF}" \
--pid "${PHP_FPM_PID}"
local i=0
local timeout=5
while [ ! -f "${PHP_FPM_PID}" ] && [ $i -le $timeout ]; do
sleep 1
i=$(($i + 1))
done
[ $timeout -gt $i ]
eend $?
}
stop() {
ebegin "Stopping PHP FastCGI Process Manager"
set_phpvars
start-stop-daemon --signal QUIT \
--stop \
--exec "${PHP_FPM_BIN}" \
--pidfile "${PHP_FPM_PID}"
eend $?
}
reload() {
ebegin "Reloading PHP FastCGI Process Manager"
set_phpvars
[ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}")
eend $?
}
configtest() {
ebegin "Testing PHP FastCGI Process Manager configuration"
set_phpvars
"${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test
eend $?
}
|