Current File : //usr/local/apps/php81/bin/fpmctl81
#!/bin/sh

### BEGIN INIT INFO
# Provides:          php-fpm81
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm81 daemon
# Description:       starts php-fpm81 daemon
### END INIT INFO

exec="/usr/local/apps/php81/sbin/php-fpm"
prog="php-fpm"
lockfile=/var/lock/subsys/php-fpm81
pidfile=/var/run/php-fpm.pid
OPTIONS="-R --pid /var/run/php-fpm.pid --fpm-config /usr/local/apps/php81/etc/php-fpm.conf -c /usr/local/apps/php81/etc/php.ini"

start() {
    [ -x $exec ] || exit 5
    echo -n "Starting $prog: "
    if [ ! -f $pidfile ]; then
		#groupadd emps > /dev/null 2>&1
		#useradd -r -g emps emps > /dev/null 2>&1
		$exec $OPTIONS
		if [ $? = 0 ]; then
			if [ -d /var/lock/subsys ] ; then
				touch $lockfile
			fi
			echo "[ OK ]"
		fi
	else
		echo "$prog already running"
	fi
    return 0
}

stop() {
    echo -n "Stopping $prog: "
	if [ -f $pidfile ]; then
		PID=`cat $pidfile`
		kill $PID > /dev/null 2>&1
        PID=0
        if [ -f $lockfile ] ; then
			rm -rf $lockfile
		fi
		sleep 1
        rm -rf ${pidfile}
		echo "[ OK ]"
	else
		echo "$prog stopped"
	fi
	
    return 0
}

status() {
	if [ ! -f $pidfile ] ; then
    	echo "$prog stopped"
	else
		PID=`cat $pidfile`
    	echo "$prog (pid $PID) is running..."
	fi
}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

case "$1" in
    start)
        $1
        ;;
    stop)
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        $1
        ;;
    status)
		$1
		;;
    force-reload)
        force_reload
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|reload|status|force-reload}"
        exit 2
esac
exit $?