From 0b543a47c776dade946c9a8d174a94363a0a3f86 Mon Sep 17 00:00:00 2001 From: Kevin Kamps Date: Wed, 29 May 2019 11:54:02 +0200 Subject: [PATCH] Added more logging to consul --- registry/consul/ConsulRegistry.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/registry/consul/ConsulRegistry.go b/registry/consul/ConsulRegistry.go index 4f4da80..9412cf1 100644 --- a/registry/consul/ConsulRegistry.go +++ b/registry/consul/ConsulRegistry.go @@ -24,6 +24,7 @@ func (this *ConsulRegistry) initConsulConnection() { config.Address = this.Configuration.Url.Host config.Scheme = this.Configuration.Url.Scheme + log.Println(fmt.Sprintf("Registry - Consul: Connecting to: %s ", this.Configuration.Url)) client, err := consulapi.NewClient(config) if err != nil { log.Fatal("Registry - Consul: ", this.Configuration.Url.Scheme) @@ -84,12 +85,19 @@ func (this *ConsulRegistry) Start() { registration.Check.DeregisterCriticalServiceAfter = fmt.Sprintf("%ds", *this.Configuration.DeregisterCriticalServiceAfter) this.registrations[registration.ID] = registration - this.consulClient.Agent().ServiceRegister(registration) + err := this.consulClient.Agent().ServiceRegister(registration) + if err != nil { + log.Println("Registry - Consul: Error registering service: ", err) + } + } else if helper.IsInstanceOf(e, (*event.EndEvent)(nil)) { endEvent := e.(*event.EndEvent) log.Println("Registry - Consul: end event: ", endEvent) delete(this.registrations, endEvent.Id) - this.consulClient.Agent().ServiceDeregister(endEvent.Id) + err := this.consulClient.Agent().ServiceDeregister(endEvent.Id) + if err != nil { + log.Println("Registry - Consul: Error registering service: ", err) + } } }