Ejemplo n.º 1
0
  log.msg("Starting server: %s" % str(datetime.now()))

  server = server.Site(root)
  
  cluster_client = SinClusterClient(settings.SIN_SERVICE_NAME, settings.ZOOKEEPER_URL, settings.ZOOKEEPER_TIMEOUT)
  cluster_client.logger.setLevel(logging.DEBUG)
  cluster_client.logger.addHandler(logging.StreamHandler())
  cluster_client.add_listener(SinClusterListener())

  nodes = cluster_client.get_registered_nodes()
  if nodes.get(node_id):
    node = nodes[node_id]
    host = None
    if options.host != "":
      host = options.host
    if settings.DISABLE_HOST_CHECK or is_current_host(node.get_host(), host):
      # Force this node to be offline first.  (In the case where
      # sin_agent is stopped and then immediately restarted, the
      # ephemeral node created in the last session may still be there
      # when sin_agent is restarted.)
      cluster_client.mark_node_unavailable(node_id)
      reactor.listenTCP(node.get_port(), server)
      log.msg("Mark %s available" % node.get_url())
      cluster_client.mark_node_available(node_id, node.get_url())
    else:
      log.err("Hostname, %s, might not have been registered!" % host)
      sys.exit(1)
  else:
    log.err("Node id %d is not registered!" % node_id)
    sys.exit(1)
Ejemplo n.º 2
0
  log.msg("Starting server: %s" % str(datetime.now()))

  server = server.Site(root)
  
  cluster_client = SinClusterClient(settings.SIN_SERVICE_NAME, settings.ZOOKEEPER_URL, settings.ZOOKEEPER_TIMEOUT)
  cluster_client.logger.setLevel(logging.DEBUG)
  cluster_client.logger.addHandler(logging.StreamHandler())
  cluster_client.add_listener(SinClusterListener())

  nodes = cluster_client.get_registered_nodes()
  if nodes.get(node_id):
    node = nodes[node_id]
    host = None
    if options.host != "":
      host = options.host
    if is_current_host(node.get_host(), host):
      # Force this node to be offline first.  (In the case where
      # sin_agent is stopped and then immediately restarted, the
      # ephemeral node created in the last session may still be there
      # when sin_agent is restarted.)
      cluster_client.mark_node_unavailable(node_id)
      reactor.listenTCP(node.get_port(), server)
      log.msg("Mark %s available" % node.get_url())
      cluster_client.mark_node_available(node_id, node.get_url())
    else:
      log.err("Hostname, %s, might not have been registered!" % host)
      sys.exit(1)
  else:
    log.err("Node id %d is not registered!" % node_id)
    sys.exit(1)
Ejemplo n.º 3
0
    server = server.Site(root)

    cluster_client = SinClusterClient(settings.SIN_SERVICE_NAME,
                                      settings.ZOOKEEPER_URL,
                                      settings.ZOOKEEPER_TIMEOUT)
    cluster_client.logger.setLevel(logging.DEBUG)
    cluster_client.logger.addHandler(logging.StreamHandler())
    cluster_client.add_listener(SinClusterListener())

    nodes = cluster_client.get_registered_nodes()
    if nodes.get(node_id):
        node = nodes[node_id]
        host = None
        if options.host != "":
            host = options.host
        if settings.DISABLE_HOST_CHECK or is_current_host(
                node.get_host(), host):
            # Force this node to be offline first.  (In the case where
            # sin_agent is stopped and then immediately restarted, the
            # ephemeral node created in the last session may still be there
            # when sin_agent is restarted.)
            cluster_client.mark_node_unavailable(node_id)
            reactor.listenTCP(node.get_port(), server)
            log.msg("Mark %s available" % node.get_url())
            cluster_client.mark_node_available(node_id, node.get_url())
        else:
            log.err("Hostname, %s, might not have been registered!" % host)
            sys.exit(1)
    else:
        log.err("Node id %d is not registered!" % node_id)
        sys.exit(1)