Beispiel #1
0
def main():
    parser = optparse.OptionParser()
    parser.add_option("-d",
                      "--debug",
                      action="store_true",
                      dest="debug",
                      help="Whether to run in debug mode "
                      "(only accessible by localhost and autoreloads)")
    parser.add_option("-p",
                      "--port",
                      type="int",
                      default=-1,
                      help="The port to run on (defaults to 5000 for debug, "
                      "else defaults to 80)")
    options, _ = parser.parse_args()

    app.debug = options.debug
    port = options.port
    if options.debug:
        if port == -1:
            port = 5000
        auth.configure_app(app, required=False)
        app.run(port=port)
    else:
        if port == -1:
            port = 80
        auth.configure_app(app, required=True)
        app.run(host='0.0.0.0', port=port)
Beispiel #2
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        "-d",
        "--debug",
        action="store_true",
        dest="debug",
        help="Whether to run in debug mode " "(only accessible by localhost and autoreloads)",
    )
    parser.add_option(
        "-p",
        "--port",
        type="int",
        default=-1,
        help="The port to run on (defaults to 5000 for debug, " "else defaults to 80)",
    )
    options, _ = parser.parse_args()

    app.debug = options.debug
    port = options.port
    if options.debug:
        if port == -1:
            port = 5000
        auth.configure_app(app, required=False)
        app.run(port=port)
    else:
        if port == -1:
            port = 80
        auth.configure_app(app, required=True)
        app.run(host="0.0.0.0", port=port)
Beispiel #3
0
"""A simple web server to see and control Mr Deploy. Talks to Mr Deploy using
Redis through her assistant, Mr Assistant.
"""

import flask
import json
import redis
import subprocess

import auth


app = flask.Flask(__name__)
app.config.from_envvar('FLASK_CONFIG')
auth.configure_app(app, required=not app.debug)

red = redis.StrictRedis()


def event_stream():
    pubsub = red.pubsub()
    pubsub.subscribe(['mr_deploy_output', 'mr_deploy_status'])
    for item in pubsub.listen():
        if item['type'] == 'message':
            # This is the format for an SSE specifying an event name with data
            # See http://www.html5rocks.com/en/tutorials/eventsource/basics/
            yield 'event: %s\ndata: %s\n\n' % (item['channel'], item['data'])


@app.route('/deploy/status', methods=['GET'])