Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. DavidWittman revised this gist Mar 20, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gunicorn-upstart.conf.template
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # %(mysite)s - run %(mysite)s instances (default is the main production instance)
    # %(mysite)s - run %(mysite)s instances (default is the prod instance)
    #
    # This runs gunicorn-django for %(mysite)s; to install:
    # * sudo ln -s <this file> /etc/init/%(mysite)s
    @@ -25,7 +25,7 @@
    # * sudo start/stop/restart/reload/status %(mysite)s
    # * sudo start/stop/restart/reload/status %(mysite)s instance=testing

    description "%(mysite)s gunicorn instance, default is the main instance"
    description "%(mysite)s gunicorn instance, default is the prod instance"

    start on runlevel [2345]
    stop on runlevel [06]
  2. DavidWittman revised this gist Mar 20, 2012. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions gunicorn-upstart.conf.template
    Original file line number Diff line number Diff line change
    @@ -30,38 +30,38 @@ description "%(mysite)s gunicorn instance, default is the main instance"
    start on runlevel [2345]
    stop on runlevel [06]

    expect fork
    expect daemon

    respawn
    respawn limit 10 5

    instance ${instance:-main}
    instance ${instance:-prod}

    env APPHOME="/home/%(mysite)s/public_html"
    env USER="django"

    pre-start script
    INST=${instance:-main}
    INST=${instance:-prod}
    GUNICORN="$APPHOME/env/bin/gunicorn_django"

    test -n "$GUNICORN" -a -x "$GUNICORN" || { stop; exit 0; }
    test -d "$APPHOME" || { stop; exit 0; }
    end script

    script
    INST=${instance:-main}
    INST=${instance:-prod}
    CONF="$APPHOME/$INST/conf/gunicorn_$INST.conf.py"
    GUNICORN="$APPHOME/env/bin/gunicorn_django"

    PIDFILE="$APPHOME/$INST/run/$INST.pid"
    LOGFILE="$APPHOME/$INST/log/gunicorn.log"

    cd "$APPHOME/$INST/app"
    source "$APPHOME/"
    exec $GUNICORN --pid="$PIDFILE" --name="$INST" --user=django --group=django --config="$CONF" --daemon --log-file="$LOGFILE" 2>>"$LOGFILE"
    exec $GUNICORN --pid="$PIDFILE" --name="$INST" --user="$USER" --group="$USER" --config="$CONF" --daemon --log-file="$LOGFILE" 2>>"$LOGFILE"
    end script

    post-stop script
    INST=${instance:-main}
    INST=${instance:-prod}
    rm -rf "$APPHOME/$INST/run/$INST".{pid,sock}
    end script

  3. @m0n5t3r m0n5t3r revised this gist Feb 14, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gunicorn-upstart.conf.template
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,7 @@ end script
    script
    INST=${instance:-main}
    CONF="$APPHOME/$INST/conf/gunicorn_$INST.conf.py"
    GUNICORN="$APPHOME/env/bin/gunicorn_django"

    PIDFILE="$APPHOME/$INST/run/$INST.pid"
    LOGFILE="$APPHOME/$INST/log/gunicorn.log"
  4. @m0n5t3r m0n5t3r revised this gist Jul 30, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gunicorn-upstart.conf.template
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,7 @@ env APPHOME="/home/%(mysite)s/public_html"

    pre-start script
    INST=${instance:-main}
    GUNICORN="$APPHOME/env/bin/gunicorn_django"
    GUNICORN="$APPHOME/env/bin/gunicorn_django"

    test -n "$GUNICORN" -a -x "$GUNICORN" || { stop; exit 0; }
    test -d "$APPHOME" || { stop; exit 0; }
    @@ -55,7 +55,7 @@ script
    LOGFILE="$APPHOME/$INST/log/gunicorn.log"

    cd "$APPHOME/$INST/app"
    source "$APPHOME/"
    source "$APPHOME/"
    exec $GUNICORN --pid="$PIDFILE" --name="$INST" --user=django --group=django --config="$CONF" --daemon --log-file="$LOGFILE" 2>>"$LOGFILE"
    end script

  5. @m0n5t3r m0n5t3r created this gist Jul 30, 2010.
    67 changes: 67 additions & 0 deletions gunicorn-upstart.conf.template
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    # %(mysite)s - run %(mysite)s instances (default is the main production instance)
    #
    # This runs gunicorn-django for %(mysite)s; to install:
    # * sudo ln -s <this file> /etc/init/%(mysite)s
    # * sudo initctl reload-configuration
    #
    # it expects the following directory layout:
    #
    # /home/%(mysite)s/public_html
    # \-env -> virtualenv
    # | \-bin
    # | \-gunicorn_django
    # | \-activate
    # \-<instance>
    # | \-app -> application
    # | \-conf
    # | | \-gunicorn_<instance>.conf.py
    # | | \-<this file>
    # | \-log -> logs
    # | \-run -> pid files and the like
    # \-<instance>
    # ...
    #
    # to use:
    # * sudo start/stop/restart/reload/status %(mysite)s
    # * sudo start/stop/restart/reload/status %(mysite)s instance=testing

    description "%(mysite)s gunicorn instance, default is the main instance"

    start on runlevel [2345]
    stop on runlevel [06]

    expect fork

    respawn
    respawn limit 10 5

    instance ${instance:-main}

    env APPHOME="/home/%(mysite)s/public_html"

    pre-start script
    INST=${instance:-main}
    GUNICORN="$APPHOME/env/bin/gunicorn_django"

    test -n "$GUNICORN" -a -x "$GUNICORN" || { stop; exit 0; }
    test -d "$APPHOME" || { stop; exit 0; }
    end script

    script
    INST=${instance:-main}
    CONF="$APPHOME/$INST/conf/gunicorn_$INST.conf.py"

    PIDFILE="$APPHOME/$INST/run/$INST.pid"
    LOGFILE="$APPHOME/$INST/log/gunicorn.log"

    cd "$APPHOME/$INST/app"
    source "$APPHOME/"
    exec $GUNICORN --pid="$PIDFILE" --name="$INST" --user=django --group=django --config="$CONF" --daemon --log-file="$LOGFILE" 2>>"$LOGFILE"
    end script

    post-stop script
    INST=${instance:-main}
    rm -rf "$APPHOME/$INST/run/$INST".{pid,sock}
    end script

    # vim: set et sw=4 ts=4 sts=4