Пример #1
0
def main():
    parser = argparse.ArgumentParser(description='Run the Web Console')

    parser.add_argument('--fd', help='FD', default=None)
    parser.add_argument('--host', help='Host', default='0.0.0.0')
    parser.add_argument('--port', help='port', default=8080)
    parser.add_argument('--server', help='web server to use',
                        default=SocketIOServer)
    parser.add_argument('--endpoint', default=None,
                        help='Circus Endpoint. If not specified, Circus will '
                             'ask you which system you want to connect to')
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays Circus version and exits.')
    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")
    parser.add_argument('--ssh', default=None, help='SSH Server')

    args = parser.parse_args()

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

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

    if args.endpoint is not None:
        connect_to_circus(args.endpoint, args.ssh)

    run(app, host=args.host, port=args.port, server=args.server, fd=args.fd)
Пример #2
0
def main():
    parser = argparse.ArgumentParser(description='Run the Web Console')

    parser.add_argument('--fd', help='FD', default=None)
    parser.add_argument('--host', help='Host', default='0.0.0.0')
    parser.add_argument('--port', help='port', default=8080)
    parser.add_argument('--server',
                        help='web server to use',
                        default=SocketIOServer)
    parser.add_argument('--endpoint',
                        default=None,
                        help='Circus Endpoint. If not specified, Circus will '
                        'ask you which system you want to connect to')
    parser.add_argument('--version',
                        action='store_true',
                        default=False,
                        help='Displays Circus version and exits.')
    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")
    parser.add_argument('--ssh', default=None, help='SSH Server')
    parser.add_argument('--multicast',
                        dest="multicast",
                        default="udp://237.219.251.97:12027",
                        help="Multicast endpoint. If not specified, Circus "
                        "will use default one")

    args = parser.parse_args()

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

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

    if args.endpoint is not None:
        connect_to_circus(args.endpoint, args.ssh)

    try:
        sys.stderr.write(' ')
        quiet = False
    except IOError:
        quiet = True

    setup_auto_discovery(args.multicast)
    run(app,
        host=args.host,
        port=args.port,
        server=args.server,
        fd=args.fd,
        quiet=quiet)
Пример #3
0
def main():
    define("port", default=8080, type=int)
    parser = argparse.ArgumentParser(description='Run the Web Console')

    parser.add_argument('--fd', help='FD', default=None, type=int)
    parser.add_argument('--host', help='Host', default='0.0.0.0')
    parser.add_argument('--port', help='port', default=8080)
    parser.add_argument('--endpoint', default=None,
                        help='Circus Endpoint. If not specified, Circus will '
                             'ask you which system you want to connect to')
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays Circus version and exits.')
    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")
    parser.add_argument('--ssh', default=None, help='SSH Server')
    parser.add_argument('--multicast', dest="multicast",
                        default="udp://237.219.251.97:12027",
                        help="Multicast endpoint. If not specified, Circus "
                             "will use default one")

    args = parser.parse_args()

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

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

    # Get the tornado ioloop singleton
    loop = tornado.ioloop.IOLoop.instance()

    if args.endpoint is not None:
        connect_to_circus(loop, args.endpoint, args.ssh)

    app.auto_discovery = AutoDiscovery(args.multicast, loop)
    http_server = tornado.httpserver.HTTPServer(app)

    if args.fd:
        sock = socket.fromfd(args.fd, socket.AF_INET, socket.SOCK_STREAM)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.setblocking(0)
        http_server.add_sockets([sock])
        logger.info("Starting circus web ui on fd %d" % args.fd)
    else:
        http_server.listen(args.port, args.host)
        logger.info("Starting circus web ui on %s:%s" % (args.host, args.port))

    loop.start()
Пример #4
0
        def client_or_redirect(*fargs, **fkwargs):
            if ensure_client:
                client = get_client()
                session = get_session()

                if client is None:
                    session = get_session()
                    if session.get('endpoint', None) is not None:
                        # XXX we need to pass SSH too here
                        connect_to_circus(session['endpoint'])
                    else:
                        return redirect(url('connect'))

            return func(*fargs, **fkwargs)
Пример #5
0
        def client_or_redirect(*fargs, **fkwargs):
            if ensure_client:
                client = get_client()
                session = get_session()

                if client is None:
                    session = get_session()
                    if session.get('endpoint', None) is not None:
                        # XXX we need to pass SSH too here
                        connect_to_circus(session['endpoint'])
                    else:
                        return redirect('/connect')

            return func(*fargs, **fkwargs)
Пример #6
0
def connect():
    """Connects to the stats client, using the endpoint that's passed in the
    POST body.
    """
    def _ask_connection():
        return render_template('connect.html',
                               endpoints=app.discovery_thread.get_endpoints())

    if request.method == 'GET':
        return _ask_connection()

    elif request.method == 'POST':
        # if we got an endpoint in the POST body, store it.
        if request.forms.endpoint is None:
            return _ask_connection()

        endpoint_input = request.forms.endpoint
        endpoint_select = request.forms.endpoint_select

        if endpoint_select:
            endpoint = endpoint_select
        else:
            endpoint = endpoint_input

        client = connect_to_circus(endpoint)
        if not client.connected:
            set_message('Impossible to connect')

        redirect(url('index'))
Пример #7
0
def connect():
    """Connects to the stats client, using the endpoint that's passed in the
    POST body.
    """
    def _ask_connection():
        return render_template('connect.html',
                               endpoints=app.discovery_thread.get_endpoints())

    if request.method == 'GET':
        return _ask_connection()

    elif request.method == 'POST':
        # if we got an endpoint in the POST body, store it.
        if request.forms.endpoint is None:
            return _ask_connection()

        endpoint_input = request.forms.endpoint
        endpoint_select = request.forms.endpoint_select

        if endpoint_select:
            endpoint = endpoint_select
        else:
            endpoint = endpoint_input

        client = connect_to_circus(endpoint)
        if not client.connected:
            set_message('Impossible to connect')

        redirect(url('index'))
Пример #8
0
def main():
    parser = argparse.ArgumentParser(description='Run the Web Console')

    parser.add_argument('--fd', help='FD', default=None)
    parser.add_argument('--host', help='Host', default='0.0.0.0')
    parser.add_argument('--port', help='port', default=8080)
    parser.add_argument('--server', help='web server to use',
                        default=SocketIOServer)
    parser.add_argument('--endpoint', default=None,
                        help='Circus Endpoint. If not specified, Circus will '
                             'ask you which system you want to connect to')
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays Circus version and exits.')
    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")
    parser.add_argument('--ssh', default=None, help='SSH Server')
    parser.add_argument('--multicast', dest="multicast",
                        default="udp://237.219.251.97:12027",
                        help="Multicast endpoint. If not specified, Circus "
                             "will use default one")

    args = parser.parse_args()

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

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

    if args.endpoint is not None:
        connect_to_circus(args.endpoint, args.ssh)

    try:
        sys.stderr.write(' ')
        quiet = False
    except IOError:
        quiet = True

    setup_auto_discovery(args.multicast)
    run(app, host=args.host, port=args.port, server=args.server,
        fd=args.fd, quiet=quiet)
Пример #9
0
def main():
    parser = argparse.ArgumentParser(description='Run the Web Console')

    parser.add_argument('--fd', help='FD', default=None)
    parser.add_argument('--host', help='Host', default='0.0.0.0')
    parser.add_argument('--port', help='port', default=8080)
    parser.add_argument('--server',
                        help='web server to use',
                        default=SocketIOServer)
    parser.add_argument('--endpoint',
                        default=None,
                        help='Circus Endpoint. If not specified, Circus will '
                        'ask you which system you want to connect to')
    parser.add_argument('--version',
                        action='store_true',
                        default=False,
                        help='Displays Circus version and exits.')
    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")
    parser.add_argument('--ssh', default=None, help='SSH Server')

    args = parser.parse_args()

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

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

    if args.endpoint is not None:
        connect_to_circus(args.endpoint, args.ssh)

    run(app, host=args.host, port=args.port, server=args.server, fd=args.fd)
Пример #10
0
def connect():
    """Connects to the stats client, using the endpoint that's passed in the
    POST body.
    """
    def _ask_connection():
        return render_template('connect.html')

    if request.method == 'GET':
        return _ask_connection()

    elif request.method == 'POST':
        # if we got an endpoint in the POST body, store it.
        if request.forms.endpoint is None:
            return _ask_connection()

        endpoint = request.forms.endpoint
        client = connect_to_circus(endpoint)
        if not client.connected:
            set_message('Impossible to connect')

        redirect('/')
Пример #11
0
def main():
    define("port", default=8080, type=int)
    parser = argparse.ArgumentParser(description='Run the Web Console')

    parser.add_argument('--fd', help='FD', default=None, type=int)
    parser.add_argument('--host', help='Host', default='0.0.0.0')
    parser.add_argument('--port', help='port', default=8080)
    parser.add_argument('--endpoint',
                        default=None,
                        help='Circus Endpoint. If not specified, Circus will '
                        'ask you which system you want to connect to')
    parser.add_argument('--version',
                        action='store_true',
                        default=False,
                        help='Displays Circus version and exits.')
    parser.add_argument('--log-level',
                        dest='loglevel',
                        default='info',
                        choices=list(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")
    parser.add_argument('--ssh', default=None, help='SSH Server')
    parser.add_argument('--multicast',
                        dest="multicast",
                        default="udp://237.219.251.97:12027",
                        help="Multicast endpoint. If not specified, Circus "
                        "will use default one")

    args = parser.parse_args()

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

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

    # Get the tornado ioloop singleton
    loop = tornado.ioloop.IOLoop.instance()

    if args.endpoint is not None:
        connect_to_circus(loop, args.endpoint, args.ssh)

    app.auto_discovery = AutoDiscovery(args.multicast, loop)
    http_server = tornado.httpserver.HTTPServer(app, xheaders=True)

    if args.fd:
        sock = socket.fromfd(args.fd, socket.AF_INET, socket.SOCK_STREAM)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.setblocking(0)
        http_server.add_sockets([sock])
        logger.info("Starting circus web ui on fd %d" % args.fd)
    else:
        http_server.listen(args.port, args.host)
        logger.info("Starting circus web ui on %s:%s" % (args.host, args.port))

    loop.start()