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!