Exemplo n.º 1
0
 def __call__(self, app, host, port, use_debugger, use_reloader):
     # override the default runserver command to start a Socket.IO server
     if use_debugger is None:
         use_debugger = app.debug
         if use_debugger is None:
             use_debugger = True
     if use_reloader is None:
         use_reloader = app.debug
     socketio.run(app,
                  host=host,
                  port=port,
                  debug=use_debugger,
                  use_reloader=use_reloader**self.server_options)
Exemplo n.º 2
0
 def __call__(self, app, host, port, use_debugger, use_reloader, url):
     # override the default runserver command to start a Socket.IO server
     if use_debugger is None:
         use_debugger = app.debug
         if use_debugger is None:
             use_debugger = True
     if use_reloader is None:
         use_reloader = app.debug
     socketio.run(app,
                  host=host,
                  port=port,
                  debug=use_debugger,
                  use_reloader=use_reloader,
                  **self.server_options)
Exemplo n.º 3
0
    parser.add_option("-d", "--debug",
                      action="store_true", dest="debug", default=default_debug,
                      help=optparse.SUPPRESS_HELP)
    parser.add_option("-u", "--url", default=default_url)
    parser.add_option("-s", "--enable-ssl",
                      action="store_true", default=default_enable_ssl)
    parser.add_option("-c", "--ca-certs", default=default_ca_certs,
                      help='Required when --use-ssl is set. ' + \
                           'Path to CA file or directory [default %s]' % default_ca_certs)


    options, _ = parser.parse_args()

    # set default url, override with env for docker
    application.config['DEFAULT_URL'] = os.environ.get('HQ_DEFAULT_URL', options.url)
    application.config['ENABLE_SSL'] = os.environ.get('HQ_ENABLE_SSL', options.enable_ssl)
    application.config['CA_CERTS'] = os.environ.get('HQ_CA_CERTS', options.ca_certs)

    if is_gunicorn:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)

        # we set reloader False so gunicorn doesn't call two instances of all the Flask init functions.
        socketio.run(application, host=options.host, port=options.port, debug=options.debug, use_reloader=False)
    else:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)
        socketio.run(application, host=options.host, port=options.port, debug=options.debug)
Exemplo n.º 4
0
if __name__ == '__main__':
    # Set up the command-line options
    parser = optparse.OptionParser()
    parser.add_option("-H", "--host",
                      help="Hostname of the Flask app " + \
                           "[default %s]" % default_host,
                      default=default_host)
    parser.add_option("-P", "--port",
                      help="Port for the Flask app " + \
                           "[default %s]" % default_port,
                      default=default_port)
    parser.add_option("-d",
                      "--debug",
                      action="store_true",
                      dest="debug",
                      default=default_debug,
                      help=optparse.SUPPRESS_HELP)
    parser.add_option("-u", "--url", default=default_url)

    options, _ = parser.parse_args()

    # set default url, override with env for docker
    application.config['DEFAULT_URL'] = os.environ.get('HQ_DEFAULT_URL',
                                                       options.url)

    socketio.run(application,
                 host=options.host,
                 port=options.port,
                 debug=options.debug)
Exemplo n.º 5
0
    application.config['ENABLE_SSL'] = os.environ.get('HQ_ENABLE_SSL',
                                                      options.enable_ssl)
    application.config['CA_CERTS'] = os.environ.get('HQ_CA_CERTS',
                                                    options.ca_certs)
    application.config['VERIFY_CERTS'] = os.environ.get(
        'HQ_VERIFY_CERTS', options.verify_certs)
    application.config['CLIENT_KEY'] = os.environ.get('CLIENT_KEY',
                                                      options.client_key)
    application.config['CLIENT_CERT'] = os.environ.get('CLIENT_CERT',
                                                       options.client_cert)

    if is_gunicorn:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)

        # we set reloader False so gunicorn doesn't call two instances of all the Flask init functions.
        socketio.run(application,
                     host=options.host,
                     port=options.port,
                     debug=options.debug,
                     use_reloader=False)
    else:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)
        socketio.run(application,
                     host=options.host,
                     port=options.port,
                     debug=options.debug)
Exemplo n.º 6
0
    application.config['ENABLE_SSL'] = os.environ.get('HQ_ENABLE_SSL',
                                                      options.enable_ssl)
    application.config['CA_CERTS'] = os.environ.get('HQ_CA_CERTS',
                                                    options.ca_certs)
    application.config['VERIFY_CERTS'] = os.environ.get(
        'HQ_VERIFY_CERTS', options.verify_certs)
    application.config['CLIENT_KEY'] = os.environ.get('CLIENT_KEY',
                                                      options.client_key)
    application.config['CLIENT_CERT'] = os.environ.get('CLIENT_CERT',
                                                       options.client_cert)

    hq_host = os.environ.get('HQ_HOST', options.host)
    hq_port = os.environ.get('HQ_PORT', options.port)

    if is_gunicorn:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)

        # we set reloader False so gunicorn doesn't call two instances of all the Flask init functions.
        socketio.run(application,
                     hq_host,
                     hq_port,
                     debug=options.debug,
                     use_reloader=False)
    else:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)
        socketio.run(application, hq_host, hq_port, debug=options.debug)
Exemplo n.º 7
0
def run_application():
    print('Routing to main')
    parser = optparse.OptionParser()
    parser.add_option("-H", "--host",
                      help="Hostname of the Flask app " + \
                           "[default %s]" % default_host,
                      default=default_host)
    parser.add_option("-P", "--port",
                      help="Port for the Flask app " + \
                           "[default %s]" % default_port,
                      default=default_port)
    parser.add_option("-d",
                      "--debug",
                      action="store_true",
                      dest="debug",
                      default=default_debug,
                      help=optparse.SUPPRESS_HELP)
    parser.add_option("-u", "--url", default=default_url)
    parser.add_option("-s",
                      "--enable-ssl",
                      action="store_true",
                      default=default_enable_ssl)
    parser.add_option("-c", "--ca-certs", default=default_ca_certs,
                      help='Required when --use-ssl is set. ' + \
                           'Path to CA file or directory [default %s]' % default_ca_certs)
    parser.add_option("-v",
                      "--verify_certs",
                      default=default_verify_certs,
                      help='Set to False when using self-signed certs.')
    parser.add_option("-x",
                      "--client_cert",
                      default=default_client_cert,
                      help='Set to path of the client cert file.')
    parser.add_option("-X",
                      "--client_key",
                      default=default_client_key,
                      help='Set to path of the client key file.')

    options, _ = parser.parse_args()

    application.config['DEFAULT_URL'] = os.environ.get('HQ_DEFAULT_URL',
                                                       options.url)
    application.config['ENABLE_SSL'] = os.environ.get('HQ_ENABLE_SSL',
                                                      options.enable_ssl)
    application.config['CA_CERTS'] = os.environ.get('HQ_CA_CERTS',
                                                    options.ca_certs)
    application.config['VERIFY_CERTS'] = os.environ.get(
        'HQ_VERIFY_CERTS', options.verify_certs)
    application.config['CLIENT_KEY'] = os.environ.get('CLIENT_KEY',
                                                      options.client_key)
    application.config['CLIENT_CERT'] = os.environ.get('CLIENT_CERT',
                                                       options.client_cert)
    if is_gunicorn:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)

        # we set reloader False so gunicorn doesn't call two instances of all the Flask init functions.
        socketio.run(application,
                     host=options.host,
                     port=options.port,
                     debug=options.debug,
                     use_reloader=False)
    else:
        if options.debug:
            config = find_config('logger_debug.json')
            logging.config.dictConfig(config)
        socketio.run(application,
                     host=options.host,
                     port=options.port,
                     debug=options.debug)