blob: 37e7e02852106ca2d23a099d362dfe5c37750c9e (
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
86
87
|
#!/sbin/openrc-run
# If you want to run separate master process per pool, then create a symlink
# to this runscript for each pool. In that mode, the php-fpm daemon is started
# as nobody by default. You can override the user (and group) by declaring
# variable "user" and optionally "group" in conf.d file, or in the $fpm_config
# file (the former has precedence).
: ${name:="PHP FastCGI Process Manager"}
command="/usr/sbin/php-fpm7.1"
command_background="yes"
start_stop_daemon_args="--quiet"
pidfile="/run/$RC_SVCNAME/php-fpm.pid"
retry="SIGTERM/20"
extra_commands="checkconfig"
extra_started_commands="reload reopen"
description_checkconfig="Run php-fpm config check"
description_reload="Gracefully reload workers and config"
description_reopen="Reopen log files"
required_files="$fpm_config"
depend() {
need net
before apache2 lighttpd nginx
}
init_vars() {
# Defaults for single master process with multiple pools
if [ "$RC_SVCNAME" = "php-fpm7.1" ]; then
: ${fpm_config:="/etc/php7.1/php-fpm.conf"}
: ${user:="root"}
# Defaults for master process per pool
else
: ${fpm_config="/etc/php7.1/php-fpm.d/${RC_SVCNAME#php-fpm7.1.}.conf"}
: ${user:="$(conf_get user)"}
: ${user:="nobody"}
: ${group:="$(conf_get group)"}
fi
command_args="--nodaemonize --fpm-config $fpm_config"
start_stop_daemon_args="$start_stop_daemon_args
--user $user ${group:+"--group $group"}"
}
start_pre() {
checkconfig || return 1
# If unix socket is used (instead of TCP/IP), then ensure that the
# directory exists and has correct privileges.
local listen="$(conf_get listen)"
if [ "${listen:0:1}" = "/" ]; then
checkpath -d -o $user:$group "${listen%/*}"
fi
checkpath -d "${pidfile%/*}"
}
reload() {
ebegin "Reloading $RC_SVCNAME"
start-stop-daemon --signal USR2 --pidfile "$pidfile"
eend $?
}
reopen() {
ebegin "Reopening $RC_SVCNAME log files"
start-stop-daemon --signal USR1 --pidfile "$pidfile"
eend $?
}
checkconfig() {
init_vars
ebegin "Checking $fpm_config"
local out
out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || {
printf "%s\n" "$out"
eend 1 "failed, please correct errors above"
return 1
}
}
conf_get() {
local key="$1"
sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1
}
|