Skip to content

Instantly share code, notes, and snippets.

@a-yasui
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-yasui/a3d70972555a7079caa5 to your computer and use it in GitHub Desktop.
Save a-yasui/a3d70972555a7079caa5 to your computer and use it in GitHub Desktop.
#! /bin/sh
#
# chkconfig: - 84 16
# description: PHP FastCGI Process Manager
# processname: php-fpm
# config: /home/user/.phpenv/versions/5.4.37/etc/php-fpm.conf
# pidfile: /var/run/php-fpm.pid
# this source is https://forums.aws.amazon.com/message.jspa?messageID=283298
#
# Standard LSB functions
#. /lib/lsb/init-functions
# Source function library.
. /etc/init.d/functions
# Check that networking is up.
. /etc/sysconfig/network
if [ "$NETWORKING" = "no" ]
then
exit 0
fi
base='/home/user/.phpenv/versions/5.4.37'
RETVAL=0
prog="php-fpm"
pidfile=${PIDFILE-/var/run/php-fpm.pid}
lockfile=${LOCKFILE-/var/lock/subsys/php-fpm}
phpfpm=${base}/sbin/php-fpm
start () {
echo -n $"Starting $prog: "
dir=$(dirname ${pidfile})
[ -d $dir ] || mkdir $dir
daemon --pidfile ${pidfile} ${base}/sbin/php-fpm
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
}
stop () {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} php-fpm
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f ${lockfile} ${pidfile}
fi
}
restart () {
stop
start
}
reload () {
echo -n $"Reloading $prog: "
killproc -p ${pidfile} php-fpm -USR2
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} php-fpm
RETVAL=$?
;;
restart)
restart
;;
reload|force-reload)
reload
;;
condrestart|try-restart)
[ -f ${lockfile} ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|try-restart}"
RETVAL=2
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment