Websmurf

php-fcgi starter

May 3rd, 2012
222
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: php-fcgi-songteksten.net
  4. # Required-Start: $network $syslog
  5. # Required-Stop: $network
  6. # Default-Start: 2 3 5
  7. # Default-Stop:
  8. # Description: Start Nginx PHP fcgi server for songteksten.net
  9. ### END INIT INFO
  10.  
  11. BIND=127.0.0.1:9000
  12. USER=songteksten.net
  13. PHP_FCGI_CHILDREN=8
  14. PHP_FCGI_MAX_REQUESTS=2500
  15. PHP_CGI=/usr/bin/php-cgi
  16. PHP_CGI_NAME=`basename $PHP_CGI`
  17. PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS PHPRC=/home/songteksten.net/etc/php5 $PHP_CGI -b $BIND"
  18. RETVAL=0
  19. start() {
  20. echo -n "Starting PHP FastCGI: "
  21. start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
  22. RETVAL=$?
  23. echo "$PHP_CGI_NAME."
  24. }
  25. stop() {
  26. echo -n "Stopping PHP FastCGI: "
  27. killall -q -w -u $USER $PHP_CGI
  28. RETVAL=$?
  29. echo "$PHP_CGI_NAME."
  30. }
  31. case "$1" in
  32. start)
  33. start
  34. ;;
  35. stop)
  36. stop
  37. ;;
  38. restart)
  39. stop
  40. start
  41. ;;
  42. *)
  43. echo "Usage: php-fcgi {start|stop|restart}"
  44. exit 1
  45. ;;
  46. esac
  47. exit $RETVAL
RAW Paste Data