SOURCES: php-fpm.init - partially pldize

glen glen at pld-linux.org
Mon Nov 3 22:09:01 CET 2008


Author: glen                         Date: Mon Nov  3 21:09:01 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- partially pldize

---- Files affected:
SOURCES:
   php-fpm.init (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/php-fpm.init
diff -u SOURCES/php-fpm.init:1.1 SOURCES/php-fpm.init:1.2
--- SOURCES/php-fpm.init:1.1	Mon Nov  3 21:58:14 2008
+++ SOURCES/php-fpm.init	Mon Nov  3 22:08:55 2008
@@ -1,28 +1,42 @@
-#! /bin/sh
+#!/bin/sh
+#
+# php-fpm	PHP FastCGI Process Manager
+#
+# chkconfig:	345 80 30
+#
+# description:	PHP FastCGI Process Manager
+#
+# processname:	php.fpm
+# config:	/etc/php/fpm.conf
+# pidfile:	/var/run/php/fpm.pid
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
 
 php_fpm_BIN=/usr/bin/php-cgi
 php_fpm_CONF=/etc/php/fpm.conf
 php_fpm_PID=/var/run/php/fpm.pid
 
-
 php_opts="--fpm-config $php_fpm_CONF"
 
-
-wait_for_pid () {
-	try=0
-
-	while test $try -lt 35 ; do
-
+wait_for_pid() {
+	local try=0
+	while test $try -lt 35; do
 		case "$1" in
 			'created')
-			if [ -f "$2" ] ; then
+			if [ -f "$2" ]; then
 				try=''
 				break
 			fi
 			;;
 
 			'removed')
-			if [ ! -f "$2" ] ; then
+			if [ ! -f "$2" ]; then
 				try=''
 				break
 			fi
@@ -32,108 +46,137 @@
 		echo -n .
 		try=`expr $try + 1`
 		sleep 1
-
 	done
-
 }
 
-case "$1" in
-	start)
-		echo -n "Starting php_fpm "
-
-		$php_fpm_BIN --fpm $php_opts
-
-		if [ "$?" != 0 ] ; then
-			echo " failed"
-			exit 1
-		fi
+start() {
+	echo -n "Starting php_fpm "
 
-		wait_for_pid created $php_fpm_PID
+	$php_fpm_BIN --fpm $php_opts
 
-		if [ -n "$try" ] ; then
-			echo " failed"
-			exit 1
-		else
-			echo " done"
-		fi
-	;;
+	if [ "$?" != 0 ] ; then
+		echo " failed"
+		exit 1
+	fi
 
-	stop)
-		echo -n "Shutting down php_fpm "
+	wait_for_pid created $php_fpm_PID
 
-		if [ ! -r $php_fpm_PID ] ; then
-			echo "warning, no pid file found - php-fpm is not running ?"
-			exit 1
-		fi
+	if [ -n "$try" ] ; then
+		echo " failed"
+		exit 1
+	else
+		echo " done"
+	fi
+}
 
-		kill -TERM `cat $php_fpm_PID`
+stop() {
+	echo -n "Shutting down php_fpm "
 
-		wait_for_pid removed $php_fpm_PID
+	if [ ! -r $php_fpm_PID ] ; then
+		echo "warning, no pid file found - php-fpm is not running ?"
+		exit 1
+	fi
 
-		if [ -n "$try" ] ; then
-			echo " failed"
-			exit 1
-		else
-			echo " done"
-		fi
-	;;
+	kill -TERM `cat $php_fpm_PID`
 
-	quit)
-		echo -n "Gracefully shutting down php_fpm "
+	wait_for_pid removed $php_fpm_PID
 
-		if [ ! -r $php_fpm_PID ] ; then
-			echo "warning, no pid file found - php-fpm is not running ?"
-			exit 1
-		fi
+	if [ -n "$try" ] ; then
+		echo " failed"
+		exit 1
+	else
+		echo " done"
+	fi
+}
 
-		kill -QUIT `cat $php_fpm_PID`
+quit() {
+	echo -n "Gracefully shutting down php_fpm "
 
-		wait_for_pid removed $php_fpm_PID
+	if [ ! -r $php_fpm_PID ] ; then
+		echo "warning, no pid file found - php-fpm is not running ?"
+		exit 1
+	fi
 
-		if [ -n "$try" ] ; then
-			echo " failed"
-			exit 1
-		else
-			echo " done"
-		fi
-	;;
+	kill -QUIT `cat $php_fpm_PID`
 
-	restart)
-		$0 stop
-		$0 start
-	;;
+	wait_for_pid removed $php_fpm_PID
 
-	reload)
+	if [ -n "$try" ] ; then
+		echo " failed"
+		exit 1
+	else
+		echo " done"
+	fi
+}
 
-		echo -n "Reload service php-fpm "
+reload() {
+	echo -n "Reload service php-fpm "
 
-		if [ ! -r $php_fpm_PID ] ; then
-			echo "warning, no pid file found - php-fpm is not running ?"
-			exit 1
-		fi
+	if [ ! -r $php_fpm_PID ] ; then
+		echo "warning, no pid file found - php-fpm is not running ?"
+		exit 1
+	fi
 
-		kill -USR2 `cat $php_fpm_PID`
+	kill -USR2 `cat $php_fpm_PID`
+	echo " done"
+}
 
-		echo " done"
-	;;
+condrestart() {
+	if [ -f /var/lock/subsys/php-fpm ]; then
+		stop
+		start
+	else
+		msg_not_running php-fpm
+		RETVAL=$1
+	fi
+}
 
-	logrotate)
+flush-logs() {
+	echo -n "Re-opening php-fpm log file "
 
-		echo -n "Re-opening php-fpm log file "
+	if [ ! -r $php_fpm_PID ] ; then
+		echo "warning, no pid file found - php-fpm is not running ?"
+		exit 1
+	fi
 
-		if [ ! -r $php_fpm_PID ] ; then
-			echo "warning, no pid file found - php-fpm is not running ?"
-			exit 1
-		fi
+	kill -USR1 `cat $php_fpm_PID`
 
-		kill -USR1 `cat $php_fpm_PID`
+	echo " done"
+}
 
-		echo " done"
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+  	start
 	;;
-
-	*)
-		echo "Usage: $0 {start|stop|quit|restart|reload|logrotate}"
-		exit 1
+  stop)
+  	stop
+	;;
+  restart)
+	stop
+	start
+	;;
+  try-restart)
+	condrestart 0
+	;;
+  reload|force-reload)
+	reload
+	;;
+  quit) # graceful shutdown
+  	quit
+	;;
+  flush-logs|logrotate)
+  	flush-logs
+	;;
+  status)
+	status php-fpm php.fpm
+	RETVAL=$?
+	;;
+  *)
+	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}"
+	exit 3
 	;;
-
 esac
+
+exit $RETVAL
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/php-fpm.init?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list