summaryrefslogtreecommitdiffstats
path: root/php-fpm.init
blob: 63aac661112906a72d4b4f45a05bba9671db1ea0 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#! /bin/sh
#
# chkconfig: - 84 16
# description:	PHP FastCGI Process Manager
# processname: php-fpm
# config: /etc/php-fpm.conf
# config: /etc/sysconfig/php-fpm
# pidfile: /var/run/php-fpm/php-fpm.pid
#
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Short-Description: start and stop PHP FPM
# Description: PHP FastCGI Process Manager
### END INIT INFO

# Standard LSB functions
#. /lib/lsb/init-functions

# Source function library.
. /etc/init.d/functions

# Check that networking is up.
. /etc/sysconfig/network

# Additional environment file
if [ -f /etc/sysconfig/php-fpm ]; then
      . /etc/sysconfig/php-fpm
fi

if [ "$NETWORKING" = "no" ]
then
	exit 0
fi

RETVAL=0
prog="php-fpm"
pidfile=${PIDFILE-/var/run/php-fpm/php-fpm.pid}
lockfile=${LOCKFILE-/var/lock/subsys/php-fpm}

start () {
	echo -n $"Starting $prog: "
	dir=$(dirname ${pidfile})
	[ -d $dir ] || mkdir $dir
	daemon --pidfile ${pidfile} /usr/sbin/php-fpm --daemonize
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch ${lockfile}
}
stop () {
	echo -n $"Stopping $prog: "
	killproc -p ${pidfile} php-fpm
	RETVAL=$?
	echo
	if [ $RETVAL -eq 0 ] ; then
		rm -f ${lockfile} ${pidfile}
	fi
}

restart () {
        stop
        start
}

reload () {
	echo -n $"Reloading $prog: "
	if ! /usr/sbin/php-fpm --test ; then
	        RETVAL=6
	        echo $"not reloading due to configuration syntax error"
	        failure $"not reloading $prog due to configuration syntax error"
	else
		killproc -p ${pidfile} php-fpm -USR2
		RETVAL=$?
	fi
	echo
}


# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status -p ${pidfile} php-fpm
	RETVAL=$?
	;;
  restart)
	restart
	;;
  reload|force-reload)
	reload
	;;
  configtest)
 	/usr/sbin/php-fpm --test
	RETVAL=$?
	;;
  condrestart|try-restart)
	[ -f ${lockfile} ] && restart || :
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|try-restart|configtest}"
	RETVAL=2
        ;;
esac

exit $RETVAL