Skip to content

Instantly share code, notes, and snippets.

@Koc
Created December 20, 2011 10:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Koc/1501185 to your computer and use it in GitHub Desktop.
Save Koc/1501185 to your computer and use it in GitHub Desktop.
start-stop-daemon php example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
NAME="brouzie-php-53"
RUN_AS_USER=brouzie
PHP_FCGI_CHILDREN=3
PHP_FCGI_MAX_REQUESTS=200
PHP_CGI=/opt/php/5.3.8/bin/php-cgi
PHP_CGI_BIND="/home/$RUN_AS_USER/php/$NAME.sock"
PHP_CGI_OPTS="-b $PHP_CGI_BIND"
DAEMON="/usr/bin/env"
DAEMON_OPTS="- PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI $PHP_CGI_OPTS"
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
echo -n "Starting daemon: "$NAME
start-stop-daemon --start --quiet --chuid $RUN_AS_USER --exec $DAEMON -- $DAEMON_OPTS &
echo "."
;;
stop)
echo -n "Stopping daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --exec $PHP_CGI -- $PHP_CGI_OPTS
echo "."
;;
restart)
echo -n "Restarting daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --exec $PHP_CGI -- $PHP_CGI_OPTS --retry 30
start-stop-daemon --start --quiet --chuid $RUN_AS_USER --exec $DAEMON -- $DAEMON_OPTS &
echo "."
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment