Skip to content

Instantly share code, notes, and snippets.

@john2x
Last active May 19, 2016 23:41
Show Gist options
  • Select an option

  • Save john2x/10339486 to your computer and use it in GitHub Desktop.

Select an option

Save john2x/10339486 to your computer and use it in GitHub Desktop.

Revisions

  1. john2x revised this gist May 2, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion uwsgi-emperor
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,7 @@ fi

    set -e

    DAEMON_OPTS="--daemonize --emperor $VASALS --die-on-term --master --logto $EMPEROR_LOGS"
    DAEMON_OPTS="--emperor $VASALS --die-on-term --master --daemonize $EMPEROR_LOGS"

    case "$1" in
    start)
  2. john2x revised this gist Apr 10, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions uwsgi-emperor
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    #!/bin/sh

    ### BEGIN INIT INFO
    # Provides: uwsgi
    # Provides: uwsgi-emperor
    # Required-Start: $all
    # Required-Stop: $all
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: starts the uwsgi app server
    # Short-Description: starts the uwsgi emperor app server
    # Description: starts uwsgi app server using start-stop-daemon
    ### END INIT INFO

  3. john2x created this gist Apr 10, 2014.
    73 changes: 73 additions & 0 deletions uwsgi-emperor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@
    #!/bin/sh

    ### BEGIN INIT INFO
    # Provides: uwsgi
    # Required-Start: $all
    # Required-Stop: $all
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: starts the uwsgi app server
    # Description: starts uwsgi app server using start-stop-daemon
    ### END INIT INFO

    #
    # modified from https://gist.github.com/asmallteapot/1633492#file-init_uwsgi-sh
    #

    PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/local/bin/uwsgi

    NAME=uwsgi-emperor
    DESC=uwsgi-emperor

    # modify as needed
    VASALS=/var/www/*/conf/uwsgi.ini
    EMPEROR_LOGS=/var/log/uwsgi/emperor.log

    test -x $DAEMON || exit 0

    # Include uwsgi defaults if available
    if [ -f /etc/default/uwsgi ] ; then
    . /etc/default/uwsgi
    fi

    set -e

    DAEMON_OPTS="--daemonize --emperor $VASALS --die-on-term --master --logto $EMPEROR_LOGS"

    case "$1" in
    start)
    echo -n "Starting $DESC: "
    start-stop-daemon --start --exec $DAEMON -- $DAEMON_OPTS
    echo "$NAME."
    ;;
    stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon --signal 3 --quiet --retry 2 --stop \
    --exec $DAEMON
    echo "$NAME."
    ;;
    reload)
    killall -1 $DAEMON
    ;;
    force-reload)
    killall -15 $DAEMON
    ;;
    restart)
    echo -n "Restarting $DESC: "
    start-stop-daemon --signal 3 --quiet --retry 2 --stop \
    --exec $DAEMON
    sleep 1
    start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
    echo "$NAME."
    ;;
    status)
    killall -10 $DAEMON
    ;;
    *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
    exit 1
    ;;
    esac
    exit 0