Skip to content

Instantly share code, notes, and snippets.

@Koc
Created December 20, 2011 10:50

Revisions

  1. Koc revised this gist Dec 20, 2011. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,16 @@ set -e

    NAME="brouzie-php-53"
    RUN_AS_USER=brouzie
    DAEMON=/opt/php/5.3.8/bin/php-cgi
    DAEMON_OPTS="-b /home/brouzie/php/5.3.8.sock"

    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"

    @@ -18,12 +26,12 @@ case "$1" in
    ;;
    stop)
    echo -n "Stopping daemon: "$NAME
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON -- $DAEMON_OPTS
    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 $DAEMON -- $DAEMON_OPTS --retry 30
    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 "."
    ;;
  2. Koc revised this gist Dec 20, 2011. 1 changed file with 16 additions and 16 deletions.
    32 changes: 16 additions & 16 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -12,25 +12,25 @@ 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 "."
    ;;
    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 $DAEMON -- $DAEMON_OPTS
    echo "."
    ;;
    restart)
    echo -n "Restarting daemon: "$NAME
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON -- $DAEMON_OPTS --retry 30
    start-stop-daemon --start --quiet --chuid $RUN_AS_USER --exec $DAEMON -- $DAEMON_OPTS &
    echo "."
    ;;
    echo -n "Stopping daemon: "$NAME
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON -- $DAEMON_OPTS
    echo "."
    ;;
    restart)
    echo -n "Restarting daemon: "$NAME
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON -- $DAEMON_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
    echo "Usage: "$1" {start|stop|restart}"
    exit 1
    esac

    exit 0
  3. Koc created this gist Dec 20, 2011.
    36 changes: 36 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/bin/sh

    # Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
    set -e

    NAME="brouzie-php-53"
    RUN_AS_USER=brouzie
    DAEMON=/opt/php/5.3.8/bin/php-cgi
    DAEMON_OPTS="-b /home/brouzie/php/5.3.8.sock"

    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 $DAEMON -- $DAEMON_OPTS
    echo "."
    ;;
    restart)
    echo -n "Restarting daemon: "$NAME
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON -- $DAEMON_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