Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Commit

Permalink
Added more logging to consul
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Kamps committed May 29, 2019
1 parent b81694f commit 0b543a4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions registry/consul/ConsulRegistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit 0b543a4

Please sign in to comment.