10

We have a number of Spring Boot applications that register themselves with Consul (via Spring Cloud Consul). If I stop those applications via docker-compose stop myservice then they de-register themselves correctly and disappear from Consul.

If I use docker-compose kill myservice then the deregistration doesn't happen. I understand that on a UNIX system it's impossible to catch the SIGKILL event, so there's no way to force the de-registration.

What we're therefore seeing is services in Consul that never removed (marked as critical but still visible in the UI). Is there a way to force Consul to refresh what's registered, so that the dead services are removed?

Thanks

Nick

nickcodefresh
  • 887
  • 2
  • 10
  • 25
  • Possible duplicate of [Consul deregister 'failing' services](https://stackoverflow.com/questions/40010594/consul-deregister-failing-services) – janisz Jul 24 '17 at 11:07

1 Answers1

9

It seems, that you have to use Consul HTTP API and manually deregister unavailable services. API gives you 2 different ways to deregister some service, the first one via agent endpoint like so

curl -v -X PUT http://%CONSUL_IP%:8500/v1/agent/service/deregister/<ServiceID>

and the second via catalog. Unfortunately in both cases you have to make http-request manually.

Stanislav
  • 27,441
  • 9
  • 87
  • 82
  • 1
    Is there a better solution for this? Right now we are also having same issue and we are manually `deregistering` the orphaned or dead consul services using the Consul HTTP API. – user3379502 Jun 30 '22 at 16:22