Beispiel #1
0
def main():
    parser = argparse.ArgumentParser(description='Runs a Meta proxy.')

    # other arguments
    parser.add_argument('--version',
                        action='store_true',
                        default=False,
                        help='Displays version and exits.')
    parser.add_argument('--host',
                        default='localhost',
                        help='Host of the server')
    parser.add_argument('--port',
                        default=9998,
                        type=int,
                        help='Port of the server')

    parser.add_argument('--log-level',
                        dest='loglevel',
                        default='info',
                        choices=LOG_LEVELS.keys() +
                        [key.upper() for key in LOG_LEVELS.keys()],
                        help="log level")
    parser.add_argument('--log-output',
                        dest='logoutput',
                        default='-',
                        help="log output")

    # parsing the provided args
    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    # configure the logger
    configure_logger(logger, args.loglevel, args.logoutput)
    http_server = MetaProxy(args.host, args.port)

    logger.info('Starting the Meta server: http://%s:%s' %
                (args.host, args.port))

    try:
        http_server.serve_forever()
    except KeyboardInterrupt:
        sys.exit(0)
    finally:
        logger.info('Bye!')
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser(description='Runs a Meta proxy.')

    # other arguments
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays version and exits.')
    parser.add_argument('--host', default='localhost',
                        help='Host of the server')
    parser.add_argument('--port', default=9998, type=int,
                        help='Port of the server')

    parser.add_argument('--log-level', dest='loglevel', default='info',
                        choices=LOG_LEVELS.keys() + [key.upper() for key in
                                                     LOG_LEVELS.keys()],
                        help="log level")
    parser.add_argument('--log-output', dest='logoutput', default='-',
                        help="log output")

    # parsing the provided args
    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    # configure the logger
    configure_logger(logger, args.loglevel, args.logoutput)
    http_server = MetaProxy(args.host, args.port)

    logger.info('Starting the Meta server: http://%s:%s' %
                (args.host, args.port))

    try:
        http_server.serve_forever()
    except KeyboardInterrupt:
        sys.exit(0)
    finally:
        logger.info('Bye!')
Beispiel #3
0
        from vaurien.webserver import get_config
        from gevent.pywsgi import WSGIServer

        config = get_config()
        config.registry['proxy'] = proxy
        app = config.make_wsgi_app()

        # configure the web app logger
        # configure_logger(app.logger, args.loglevel, args.logoutput)

        # app.run(host=args.http_host, port=args.http_port)
        http_server = WSGIServer((args.http_host, args.http_port), app,
                                 log=DevNull())

        http_server.start()
        logger.info('Started the HTTP server: http://%s:%s' %
                    (args.http_host, args.http_port))
    else:
        # per default, we want to randomize
        proxy = RandomProxy(**proxy_args)

    try:
        proxy.serve_forever()
    except KeyboardInterrupt:
        sys.exit(0)
    finally:
        logger.info('Bye!')


if __name__ == '__main__':
    main()
Beispiel #4
0
        from gevent.pywsgi import WSGIServer

        config = get_config()
        config.registry['proxy'] = proxy
        app = config.make_wsgi_app()

        # configure the web app logger
        # configure_logger(app.logger, args.loglevel, args.logoutput)

        # app.run(host=args.http_host, port=args.http_port)
        http_server = WSGIServer((args.http_host, args.http_port),
                                 app,
                                 log=DevNull())

        http_server.start()
        logger.info('Started the HTTP server: http://%s:%s' %
                    (args.http_host, args.http_port))
    else:
        # per default, we want to randomize
        proxy = RandomProxy(**proxy_args)

    try:
        proxy.serve_forever()
    except KeyboardInterrupt:
        sys.exit(0)
    finally:
        logger.info('Bye!')


if __name__ == '__main__':
    main()
Beispiel #5
0
        proxy = OnTheFlyProxy(**proxy_args)
        from vaurien.webserver import get_config
        from gevent.pywsgi import WSGIServer

        config = get_config()
        config.registry["proxy"] = proxy
        app = config.make_wsgi_app()

        # configure the web app logger
        # configure_logger(app.logger, args.loglevel, args.logoutput)

        # app.run(host=args.http_host, port=args.http_port)
        http_server = WSGIServer((args.http_host, args.http_port), app, log=DevNull())

        http_server.start()
        logger.info("Started the HTTP server: http://%s:%s" % (args.http_host, args.http_port))
    else:
        # per default, we want to randomize
        proxy = RandomProxy(**proxy_args)

    try:
        proxy.serve_forever()
    except KeyboardInterrupt:
        sys.exit(0)
    finally:
        logger.info("Bye!")


if __name__ == "__main__":
    main()