#!/bin/bash
#
###############################################################################
# PACE :: PHP Asynchronous Command Engine
# (C)2022 DP Tech Solutions
# URL:    http://www.pace.tech
# Email:  support@dptechsolutions.com
###############################################################################

DAEMON_PATH="/usr/local/pace"

DAEMON=pace
DAEMONOPTS_START="start"
DAEMONOPTS_STOP="stop"

NAME=PACE
DESC="PHP Asynchronous Command Engine"
SCRIPTNAME=/etc/init.d/$NAME

case "$1" in
start)
	printf "%-50s" "Starting $NAME..."
	cd $DAEMON_PATH
	PID=`$DAEMON $DAEMONOPTS_START > /dev/null 2>&1 & echo $!`
;;
status)
        printf "%-50s" "Checking $NAME..."
        if [ -z "`ps axf | grep ${DAEMON} | grep -v grep`" ]; then
            printf "%s\n" "Service not running"
        else
            echo "Running"
        fi
;;
stop)
        printf "%-50s" "Stopping $NAME"
	cd $DAEMON_PATH
	PID=`$DAEMON $DAEMONOPTS_STOP > /dev/null 2>&1 & echo $!`
;;

restart)
  	$0 stop
  	$0 start
;;

*)
        echo "Usage: $0 {status|start|stop|restart}"
esac

exit 0