aboutsummaryrefslogtreecommitdiffstats
path: root/main/php/php-fpm.initd
blob: a7e6798087790ed350be2f66cadef545582e6830 (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
#!/sbin/openrc-run

PHP_FPM_CONF="/etc/php/php-fpm.conf"
pidfile="/var/run/php-fpm.pid"
command=/usr/bin/php-fpm

extra_commands="depend"
extra_started_commands="reload"

depend() {
	need net
	use apache2 lighttpd nginx
}

start() {
        ebegin "Starting PHP FastCGI Process Manager"
        start-stop-daemon --start --pidfile ${pidfile} --exec ${command} \
            -- --fpm-config "${PHP_FPM_CONF}" --pid "${pidfile}"
        local i=0
        local timeout=50
        while [ ! -f ${pidfile} ] && [ $i -le $timeout ]; do
            sleep 0.1
            i=$(($i + 1))
        done

        [ $timeout -gt $i ]
        eend $?
}

stop() {
        ebegin "Stopping PHP FastCGI Process Manager"
        start-stop-daemon --signal QUIT --stop --pidfile ${pidfile}
        eend $?
}

reload() {
    ebegin "Reloading PHP FastCGI Process Manager"
    [ -f ${pidfile} ] && kill -USR2 $(cat ${pidfile})
    eend $?
}