Ejemplo n.º 1
0
def stop_server():
    shared.stop()
    server_proc.join()
    chain_proc.join()
    print_log("Electrum-GRS Server stopped")
Ejemplo n.º 2
0
 def handler(signum=None, frame=None):
     print_log('Signal handler called with signal', signum)
     shared.stop()
Ejemplo n.º 3
0
def start_server(config):
    global shared, chain_proc, server_proc, dispatcher
    global tcp_server, ssl_server

    logfile = config.get('server', 'logfile')
    utils.init_logger(logfile)
    host = config.get('server', 'host')
    stratum_tcp_port = get_port(config, 'stratum_tcp_port')
    stratum_http_port = get_port(config, 'stratum_http_port')
    stratum_tcp_ssl_port = get_port(config, 'stratum_tcp_ssl_port')
    stratum_http_ssl_port = get_port(config, 'stratum_http_ssl_port')
    ssl_certfile = config.get('server', 'ssl_certfile')
    ssl_keyfile = config.get('server', 'ssl_keyfile')

    setup_network_params(config)

    if ssl_certfile is '' or ssl_keyfile is '':
        stratum_tcp_ssl_port = None
        stratum_http_ssl_port = None

    print_log("Starting Electrum server on", host)

    # Create hub
    dispatcher = Dispatcher(config)
    shared = dispatcher.shared

    # handle termination signals
    import signal

    def handler(signum=None, frame=None):
        print_log('Signal handler called with signal', signum)
        shared.stop()

    for sig in [signal.SIGTERM, signal.SIGHUP, signal.SIGQUIT]:
        signal.signal(sig, handler)

    # Create and register processors
    chain_proc = BlockchainProcessor(config, shared)
    dispatcher.register('blockchain', chain_proc)

    server_proc = ServerProcessor(config, shared)
    dispatcher.register('server', server_proc)

    # Create various transports we need
    if stratum_tcp_port:
        tcp_server = TcpServer(dispatcher, host, stratum_tcp_port, False, None,
                               None)
        transports.append(tcp_server)

    if stratum_tcp_ssl_port:
        ssl_server = TcpServer(dispatcher, host, stratum_tcp_ssl_port, True,
                               ssl_certfile, ssl_keyfile)
        transports.append(ssl_server)

    if stratum_http_port:
        http_server = HttpServer(dispatcher, host, stratum_http_port, False,
                                 None, None)
        transports.append(http_server)

    if stratum_http_ssl_port:
        https_server = HttpServer(dispatcher, host, stratum_http_ssl_port,
                                  True, ssl_certfile, ssl_keyfile)
        transports.append(https_server)

    for server in transports:
        server.start()
def stop_server():
    shared.stop()
    server_proc.join()
    chain_proc.join()
    print_log("Electrum-GRS Server stopped")
 def handler(signum=None, frame=None):
     print_log("Signal handler called with signal", signum)
     shared.stop()
def start_server(config):
    global shared, chain_proc, server_proc, dispatcher
    global tcp_server, ssl_server

    logfile = config.get("server", "logfile")
    utils.init_logger(logfile)
    host = config.get("server", "host")
    stratum_tcp_port = get_port(config, "stratum_tcp_port")
    stratum_http_port = get_port(config, "stratum_http_port")
    stratum_tcp_ssl_port = get_port(config, "stratum_tcp_ssl_port")
    stratum_http_ssl_port = get_port(config, "stratum_http_ssl_port")
    ssl_certfile = config.get("server", "ssl_certfile")
    ssl_keyfile = config.get("server", "ssl_keyfile")

    setup_network_params(config)

    if ssl_certfile is "" or ssl_keyfile is "":
        stratum_tcp_ssl_port = None
        stratum_http_ssl_port = None

    print_log("Starting Electrum server on", host)

    # Create hub
    dispatcher = Dispatcher(config)
    shared = dispatcher.shared

    # handle termination signals
    import signal

    def handler(signum=None, frame=None):
        print_log("Signal handler called with signal", signum)
        shared.stop()

    for sig in [signal.SIGTERM, signal.SIGHUP, signal.SIGQUIT]:
        signal.signal(sig, handler)

    # Create and register processors
    chain_proc = BlockchainProcessor(config, shared)
    dispatcher.register("blockchain", chain_proc)

    server_proc = ServerProcessor(config, shared)
    dispatcher.register("server", server_proc)

    # Create various transports we need
    if stratum_tcp_port:
        tcp_server = TcpServer(dispatcher, host, stratum_tcp_port, False, None, None)
        transports.append(tcp_server)

    if stratum_tcp_ssl_port:
        ssl_server = TcpServer(dispatcher, host, stratum_tcp_ssl_port, True, ssl_certfile, ssl_keyfile)
        transports.append(ssl_server)

    if stratum_http_port:
        http_server = HttpServer(dispatcher, host, stratum_http_port, False, None, None)
        transports.append(http_server)

    if stratum_http_ssl_port:
        https_server = HttpServer(dispatcher, host, stratum_http_ssl_port, True, ssl_certfile, ssl_keyfile)
        transports.append(https_server)

    for server in transports:
        server.start()