Hey, I am using Consul for discovery and Spring cloud config.
My issue is that if I send a SIGTERM (normal termination) to a service, it will not de-register from Consul on shutdown.
The problem is caused by starting the service with these 2 flags:
--spring.cloud.config.enabled=true --spring.cloud.config.discovery.enabled=true. If I don't use Spring cloud config (eg: local config file) the service will de-register properly.
I tried to debug it and it looks like the main cause if that the ConsulLifecycle bean will be included in the bootstrap application context (AnnotationConfigApplicationContext), and
will be properly initialized, but on shutdown it looks like only the lifecycle beans in the embedded web application context get a proper shutdown (thus stop() never gets called on consul lifecycle bean). When I exclude the flags the bootstrap app context has no lifecycle beans, and consul lifecycle is included in the web app context, and everything works as expected.
Any suggestion on how to fix this?