diff options
Diffstat (limited to 'usr/libexec/commission/commission-php-fpm')
-rwxr-xr-x | usr/libexec/commission/commission-php-fpm | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/usr/libexec/commission/commission-php-fpm b/usr/libexec/commission/commission-php-fpm new file mode 100755 index 0000000..f3a53b4 --- /dev/null +++ b/usr/libexec/commission/commission-php-fpm @@ -0,0 +1,77 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: php-fpm +# Required-Start: $remote_fs $network +# Required-Stop: $remote_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts php-fpm +# Description: starts the PHP FastCGI Process Manager daemon +### END INIT INFO + +DESC="MT php commissioning server " +NAME="php-fpm-commission" +prefix=/usr +exec_prefix=/usr + +php_fpm_BIN=/usr/sbin/php-fpm +php_fpm_CONF="/etc/${NAME}.conf" +php_fpm_PID="/var/run/${NAME}.pid" + + +php_opts="-R --fpm-config $php_fpm_CONF --pid $php_fpm_PID" +ENABLED=yes + +wait_for_pid () { + try=0 + + while test $try -lt 35 ; do + + case "$1" in + 'created') + if [ -f "$2" ] ; then + try='' + break + fi + ;; + + 'removed') + if [ ! -f "$2" ] ; then + try='' + break + fi + ;; + esac + + echo -n . + try=`expr $try + 1` + sleep 1 + + done + +} + + [ -f "/run/mt-commission" ] && . "/run/mt-commission" + if [[ $ENABLED != "yes" ]]; then + echo "$NAME: disabled in /run/mt-commission" + exit + fi + + echo -n "Starting php-fpm " + + $php_fpm_BIN --daemonize $php_opts + + if [ "$?" != 0 ] ; then + echo " failed" + exit 1 + fi + + wait_for_pid created $php_fpm_PID + + if [ -n "$try" ] ; then + echo " failed" + exit 1 + else + echo " done" + fi |