Freebsd php-fpm fastcgi server init script
floyd - Thu 29 January 2009 - freebsd, network, php
#!/bin/sh
# PROVIDE: phpfpm
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable php-fpm:
#
#phpfpm_enable="YES"
#
#
. /etc/rc.subr
name=phpfpm
rcvar=`set_rcvar`
command="/usr/local/sbin/php-fpm"
command_args=""
pidfile=/usr/local/logs/php-fpm.pid
required_files=/usr/local/etc/php-fpm.conf
# set defaults
phpfpm_enable=${phpfpm_enable:-"NO"}
start_cmd="phpfpm_start"
stop_cmd="phpfpm_stop"
restart_cmd="phpfpm_restart"
phpfpm_start()
{
if [ -f ${pidfile} ]
then
echo "php-fpm already running!"
exit 1;
fi
echo "Starting php-fpm server..."
/usr/local/bin/php-cgi --fpm
}
phpfpm_stop()
{
if [ ! -f ${pidfile} ]
then
echo "${name} is not running or pidfile not found!";
exit 1;
fi
echo "stopping ${name}..."
kill -SIGQUIT `cat ${pidfile}`
}
phpfpm_restart()
{
if [ ! -f ${pidfile} ]
then
echo "${name} is not running or pidfile not found!";
exit 1;
fi
echo "sending SIGUSR2 to php-fpm master"
kill -SIGUSR2 `cat ${pidfile}`
}
load_rc_config ${name}
run_rc_command "$1"