Skip to content

Instantly share code, notes, and snippets.

@sole
Forked from zliang-min/php-cgi.rc.sh
Created September 24, 2012 19:30
Show Gist options
  • Save sole/3777815 to your computer and use it in GitHub Desktop.
Save sole/3777815 to your computer and use it in GitHub Desktop.
php-cgi rc script for archlinux
#!/bin/bash
# vim: syntax=sh
. /etc/rc.conf
. /etc/rc.d/functions
daemon_name=php-cgi
BIND=/tmp/php-cgi.socket
USER=gimi
PHP_CGI=/usr/bin/php-cgi
PID=`pidof /usr/bin/php-cgi`
case "$1" in
start)
stat_busy "Starting $daemon_name"
[ -z "$PID" ] && /bin/su $USER -s /bin/bash -c "$PHP_CGI -b $BIND -q &" > /tmp/php-cgi.log 2>&1
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon $daemon_name
stat_done
fi
;;
stop)
stat_busy "Stopping $daemon_name"
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon $daemon_name
while [ ! -z "$(pidof $PHP_CGI)" ]; do
sleep 1;
done
stat_done
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment