Пример #1
0
def web_start(dd, host, web_port):
    """
    当service.py为入口时会调用这里
    """
    GlobalHelper.init(dd)
    # wsgi.WSGIServer((host, web_port), app, backlog=1).serve_forever(3)
    app.run(host=host, port=web_port, threaded=True)
Пример #2
0
def web_start(dd, host, web_port):
    """
    当service.py为入口时会调用这里
    """
    GlobalHelper.init(dd)
    # wsgi.WSGIServer((host, web_port), app, backlog=1).serve_forever(3)
    app.run(host=host, port=web_port, threaded=True)
Пример #3
0
def cli(host, port, wwwport):
    click.echo('\r\nService listening on %s:%s' % (
        host,
        port,
    ))

    web_list = list()
    client_connect_list = list()
    web_list.append('local: http://127.0.0.1:%s' % wwwport)
    client_connect_list.append(
        'local: python client.py --host 127.0.0.1 --port %s' % port)
    if host == '0.0.0.0':
        wan_ip = get_wan_ip()
        lan_ip = socket.gethostbyname(socket.gethostname())
        if lan_ip != wan_ip:
            web_list.append('lan  : http://%s:%s' % (lan_ip, wwwport))
            client_connect_list.append(
                'lan  : python client.py --host %s --port %s' % (lan_ip, port))

        if wan_ip:
            web_list.append(
                'wan  : http://%s:%s  PS: Maybe need to set up port forwarding'
                % (wan_ip, wwwport))
            client_connect_list.append(
                'wan  : python client.py --host %s --port %s  PS: Maybe need to set up port forwarding'
                % (wan_ip, port))

    click.echo('\r\nAccess console via:')
    for item in web_list:
        click.echo(item)

    click.echo('\r\nClient connection use:')
    for item in client_connect_list:
        click.echo(item)

    click.echo('\r\nListening ...')

    global_process_var = Manager().dict()
    GlobalHelper.init(global_process_var)

    web_ui = Process(target=web_start,
                     args=(global_process_var, host, wwwport))
    web_ui.start()

    global slave_record
    slave_record = SlaveRecord.get_instance()
    GlobalHelper.set('salve_record', slave_record.slave_record)

    socket_server(host, port)
    web_ui.join()
Пример #4
0
def cli(host, port, wwwport):
    click.echo('\r\nService listening on %s:%s' % (host, port,))

    web_list = list()
    client_connect_list = list()
    web_list.append('local: http://127.0.0.1:%s' % wwwport)
    client_connect_list.append('local: python client.py --host 127.0.0.1 --port %s' % port)
    if host == '0.0.0.0':
        wan_ip = get_wan_ip()
        lan_ip = socket.gethostbyname(socket.gethostname())
        if lan_ip != wan_ip:
            web_list.append('lan  : http://%s:%s' % (lan_ip, wwwport))
            client_connect_list.append('lan  : python client.py --host %s --port %s' % (lan_ip, port))

        if wan_ip:
            web_list.append('wan  : http://%s:%s  PS: Maybe need to set up port forwarding' % (wan_ip, wwwport))
            client_connect_list.append(
                'wan  : python client.py --host %s --port %s  PS: Maybe need to set up port forwarding' %
                (wan_ip, port))

    click.echo('\r\nAccess console via:')
    for item in web_list:
        click.echo(item)

    click.echo('\r\nClient connection use:')
    for item in client_connect_list:
        click.echo(item)

    click.echo('\r\nListening ...')

    global_process_var = Manager().dict()
    GlobalHelper.init(global_process_var)

    web_ui = Process(target=web_start, args=(global_process_var, host, wwwport))
    web_ui.start()

    global slave_record
    slave_record = SlaveRecord.get_instance()
    GlobalHelper.set('salve_record', slave_record.slave_record)

    socket_server(host, port)
    web_ui.join()