aboutsummaryrefslogtreecommitdiffstats
path: root/lang/php52/files/php-fpm.in
blob: ffa3234405ec4cb878acffb1cd89346b7c86ea4d (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: php-fpm
# REQUIRE: LOGIN
# BEFORE:  securelevel
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable php-fpm:
#
# php_fpm_enable="YES"
# php_fpm_config=""
#

. /etc/rc.subr

name="php_fpm"
rcvar=php_fpm_enable

extra_commands="reload logrotate"

command="%%PREFIX%%/bin/php-cgi"
pidfile="%%PHP_FPM_PID%%"
reload_cmd="php_fpm_reload_cmd"
logrotate_cmd="php_fpm_logrotate_cmd"

# read configuration and set defaults
load_rc_config "$name"
: ${php_fpm_enable="NO"}
: ${php_fpm_config="%%PREFIX%%/etc/php-fpm.conf"}

required_files="${php_fpm_config}"
command_args="--fpm --fpm-config ${php_fpm_config}"

php_fpm_reload_cmd () {
    if [ -z "$rc_pid" ]; then
        _run_rc_notrunning
        return 1
    fi
    echo "Reloading $name."
    kill -USR2 $rc_pid
}

php_fpm_logrotate_cmd () {
    if [ -z "$rc_pid" ]; then
        _run_rc_notrunning
        return 1
    fi
    echo "Rotating logs $name."
    kill -USR1 $rc_pid
}

run_rc_command "$1"