]> andersk Git - sql.git/commitdiff
php: init.d script
authorJoe Presbrey <presbrey@mit.edu>
Sun, 26 Sep 2010 17:01:31 +0000 (17:01 +0000)
committerJoe Presbrey <presbrey@mit.edu>
Sun, 26 Sep 2010 17:01:31 +0000 (17:01 +0000)
git-svn-id: svn://sql.mit.edu/sql@186 a142d4bd-2cfb-0310-9673-cb33a7e74f58

etc/init.d/php [new file with mode: 0755]

diff --git a/etc/init.d/php b/etc/init.d/php
new file mode 100755 (executable)
index 0000000..d8fc292
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+#  Created 2010-09-26 by presbrey@mit.edu
+#
+# php          This shell script takes care of starting and stopping PHP
+#
+# chkconfig: - 80 30
+# description: manages PHP spawned in FastCGI mode with spawn-fcgi
+# processname: php-cgi
+# config: /etc/php.ini
+
+
+# Source function library
+if [ -f /etc/rc.d/init.d/functions ]; then
+. /etc/rc.d/init.d/functions
+elif [ -f /etc/init.d/functions ]; then
+. /etc/init.d/functions
+elif [ -f /etc/rc.d/functions ]; then
+. /etc/rc.d/functions
+fi
+
+pidfile=${PIDFILE-/var/run/php.pid}
+lockfile=${LOCKFILE-/var/lock/subsys/php}
+PHP_BIN=/usr/bin/php-cgi
+PHP_SOCK=/tmp/php.sock
+PHP_USER=lighttpd
+PHP_GROUP=apache
+PHP_CHILDREN=8
+
+# Read configuration (environment etc.)
+if [ -f /etc/sysconfig/php ]; then
+    . /etc/sysconfig/php
+fi
+
+RETVAL=0
+
+# See how we were called.
+case "$1" in
+  start)
+    # Start daemons.
+    echo -n "Starting php: "
+    daemon --pidfile=${pidfile} spawn-fcgi -C $PHP_CHILDREN -f $PHP_BIN -u $PHP_USER -g $PHP_GROUP -s $PHP_SOCK -P $pidfile
+    RETVAL=$?
+    echo
+    [ $RETVAL = 0 ] && touch ${lockfile}
+    ;;
+  stop)
+    # Stop daemons.
+    echo -n "Stopping php: "
+    killproc -p ${pidfile} -d 1 $PID_BIN -9
+    RETVAL=$?
+    echo
+    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
+    ;;
+  restart)
+    $0 stop
+    $0 start
+    ;;
+  status)
+    status -p $pidfile $PHP_BIN
+    RETVAL=$?
+    ;;
+  *)
+    echo "Usage: php {start|stop|restart|reload|status}"
+    RETVAL=2
+esac
+
+exit $RETVAL
This page took 0.031692 seconds and 5 git commands to generate.