Example #1
0
def _restart_consul():
    # Services will be registered again by their script 'register_in_service_discovery'.
    agent_self_dict = consul_query('agent/self')
    node_name = agent_self_dict['Config']['NodeName']
    request_body = json.dumps({'Node': node_name})
    consul_put('catalog/deregister', data=request_body)

    os.system('consul leave')
    return wait_for_consul_ready()
Example #2
0
def _restart_consul():
    # Services will be registered again by their script 'register_in_service_discovery'.
    agent_self_dict = consul_query('agent/self')
    node_name = agent_self_dict['Config']['NodeName']
    request_body = json.dumps({'Node': node_name})
    consul_put('catalog/deregister', data=request_body)

    os.system('consul leave')
    return wait_for_consul_ready()
Example #3
0
 def on_put(self, req, resp, microservice_id):
     if not exists_service(microservice_id):
         resp.status = falcon.HTTP_404
         resp.json = {
             'error':
             'Could not find service "{microservice_id}", try registering it first.'
             .format(**locals()),
             'error_id':
             'SERVICE_NOT_FOUND',
         }
         return
     try:
         input_json = req.json
         health_check_code = input_json['health_check_code']
         health_endpoint = _get_consul_health_endpoint(health_check_code)
         r = consul_put(
             'agent/check/{health_endpoint}/service:{microservice_id}'.
             format(**locals()))
         r.raise_for_status()
     except Exception as e:
         resp.json = {
             'error':
             'Could not mark service health check status: {}'.format(
                 repr(e))
         }
         resp.status = falcon.HTTP_500
Example #4
0
def set(key, value):
    consul_put('kv/{key}'.format(**locals()), data=value)