Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
Forked from ozeias/spawn-fcgi.sh
Last active December 19, 2015 14:38

Revisions

  1. ZiTAL revised this gist Jul 10, 2013. 1 changed file with 63 additions and 59 deletions.
    122 changes: 63 additions & 59 deletions spawn-fcgi.sh
    Original file line number Diff line number Diff line change
    @@ -1,59 +1,63 @@
    ## railsbox.org:~ ozeias$ vim /etc/init.d/spawn-fcgi
    #! /bin/sh

    ### BEGIN INIT INFO
    # Provides: nginx
    # Required-Start: $all
    # Required-Stop: $all
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: starts FastCGI for PHP
    # Description: starts FastCGI for PHP using start-stop-daemon
    ### END INIT INFO

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/bin/spawn-fcgi
    NAME=spawn-fcgi
    DESC=spawn-fcgi
    DAEMON_OPTS="-f /usr/bin/php-cgi -a 127.0.0.1 -p 53987"

    test -x $DAEMON || exit 0

    set -e

    case "$1" in
    start)
    echo -n "Starting $DESC: "
    start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON -- $DAEMON_OPTS
    echo "$NAME."
    ;;
    stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON
    echo "$NAME."
    ;;
    restart|force-reload)
    echo -n "Restarting $DESC: "
    start-stop-daemon --stop --quiet --pidfile \
    /var/run/$NAME.pid --exec $DAEMON
    sleep 1
    start-stop-daemon --start --quiet --pidfile \
    /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
    echo "$NAME."
    ;;
    reload)
    echo -n "Reloading $DESC configuration: "
    start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON
    echo "$NAME."
    ;;
    *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
    exit 1
    ;;
    esac

    exit 0
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: spawn-cgi
    # Required-Start: $all
    # Required-Stop: $all
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: fastcgi for python
    # Description: fastcgi for python using nginx
    # placed in /etc/init.d.
    ### END INIT INFO
    #
    # original https://gist.github.com/ozeias/47394
    # modified to use with python
    #
    # to install in debian gnu/linux:
    # update-rc.d spawn-fcgi defaults

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/bin/spawn-fcgi
    NAME=spawn-fcgi
    DESC=spawn-fcgi

    HOST='127.0.0.1'
    PORT=9000

    FOLDER='/home/projects/zpy/private'
    SCRIPT='index.py'
    USER='zital'
    GROUP='zital'

    DAEMON_OPTS="-d ${FOLDER} -f ${FOLDER}/${SCRIPT} -a ${HOST} -p ${PORT} -P /var/run/${NAME}.pid -u ${USER} -g ${GROUP}"

    test -x $DAEMON || exit 0

    set -e

    case "$1" in
    start)
    echo -n "Starting $DESC: "
    start-stop-daemon --start --exec $DAEMON -- $DAEMON_OPTS
    ;;
    stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon --stop --pidfile /var/run/$NAME.pid
    ;;
    # restart)
    # echo -n "Restarting $DESC: "
    # start-stop-daemon --stop --quiet --pidfile \
    # /var/run/$NAME.pid --exec $DAEMON
    # sleep 1
    # start-stop-daemon --start --quiet --pidfile \
    # /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
    # echo "$NAME."
    # ;;
    *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop}" >&2
    exit 1
    ;;
    esac

    exit 0
  2. @ozeias ozeias revised this gist Jan 15, 2009. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions spawn-fcgi.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ## railsbox.org:~ ozeias$ vim /etc/init.d/spawn-fcgi
    #! /bin/sh

    ### BEGIN INIT INFO
  3. @chris chris created this gist Aug 29, 2008.
    58 changes: 58 additions & 0 deletions spawn-fcgi.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    #! /bin/sh

    ### BEGIN INIT INFO
    # Provides: nginx
    # Required-Start: $all
    # Required-Stop: $all
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: starts FastCGI for PHP
    # Description: starts FastCGI for PHP using start-stop-daemon
    ### END INIT INFO

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/bin/spawn-fcgi
    NAME=spawn-fcgi
    DESC=spawn-fcgi
    DAEMON_OPTS="-f /usr/bin/php-cgi -a 127.0.0.1 -p 53987"

    test -x $DAEMON || exit 0

    set -e

    case "$1" in
    start)
    echo -n "Starting $DESC: "
    start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON -- $DAEMON_OPTS
    echo "$NAME."
    ;;
    stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON
    echo "$NAME."
    ;;
    restart|force-reload)
    echo -n "Restarting $DESC: "
    start-stop-daemon --stop --quiet --pidfile \
    /var/run/$NAME.pid --exec $DAEMON
    sleep 1
    start-stop-daemon --start --quiet --pidfile \
    /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
    echo "$NAME."
    ;;
    reload)
    echo -n "Reloading $DESC configuration: "
    start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
    --exec $DAEMON
    echo "$NAME."
    ;;
    *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
    exit 1
    ;;
    esac

    exit 0