Is there any way to "consul reload" yourself to re-register service?

Hi, i use consul for register service python
I am having problems when using the command ‘consul reload’, it deregister all service,
Is there any way for the service to re-register itself after using this command
Sorry for my english

Hi @rainkidpk,

Yes, you can register a service by using the consul reload command. This usually means that you want to register the service by placing service configuration in the config file or the config directory for the agent. There is some more information on that in the docs.

If you are registering the service via HTTP API (i.e. by running consul service register command), you shouldn’t need to run consul reload command. But if you do run it for some reason, it won’t de-register services unless you’re running it in a dev mode without a -data-dir configuration option.

If I understood you correctly, when you run consul reload it deregisters all services? I can think of a few reasons this could happen:

  1. Configuration files provided to Consul agent either via -config-file or -config-dir parameters no longer have service definition.
  2. You were running the agent in the dev mode without -data-dir and registered the service via CLI or HTTP API. This essentially means that you are running the agent with an in-memory datastore, and so when you restart/reload it all the information that isn’t in the config files is gone.

There could be other reasons why this is happening that I couldn’t think of at the moment. If neither of the above apply to your situation, it would be helpful to learn how you’re configuring the agent and how you’re registering the service.

Hope this helps!

Hello,

Did consul reload end up working? We’re facing an issue where our consul server deregisters all services after restarting and we need a way to force all our services to register.

We’re running a single consul server and agents on all of our other ec2 instances. I’m looking for a way to tell the agent that it needs to reregister all its services with the consul server. Any help would be appreciated.

Thanks,
Sebastian

Hi @sebastian.restrepo,

Welcome to the Forum!

What version of Consul are you using? Also, is there any reason why you are running a single Consul server? Could you please share the configuration of the Consul Server agent?

Are you facing the issue when you run consul reload on the server or on Consul clients? How are you registering the services, is it by placing the service configurations in Consul data directory, or by using HTTP API?

Hi @sebastian.restrepo ,

Were able to fix this issue ? For me everytime I restart the cluster I am facing the upstream connect error as the number of instances seems to be wrong, though only one instance is running in kubernetes, it seems to be having more instances shown in the UI. My guess is, it still has the pod that were there before cluster shutdown.