diff --git a/src/caduceus/caduceus.go b/src/caduceus/caduceus.go index 5ffbed22..74200bcd 100644 --- a/src/caduceus/caduceus.go +++ b/src/caduceus/caduceus.go @@ -19,6 +19,9 @@ package main import ( "crypto/tls" "fmt" + "github.com/Comcast/webpa-common/service/monitor" + "github.com/Comcast/webpa-common/service/servicecfg" + "github.com/go-kit/kit/log/level" "net/http" _ "net/http/pprof" "net/url" @@ -35,7 +38,6 @@ import ( "github.com/Comcast/webpa-common/webhook" "github.com/Comcast/webpa-common/webhook/aws" "github.com/SermoDigital/jose/jwt" - "github.com/go-kit/kit/log/level" "github.com/gorilla/mux" "github.com/justinas/alice" "github.com/spf13/pflag" @@ -226,6 +228,40 @@ func caduceus(arguments []string) int { } } + // + // Now, initialize the service discovery infrastructure + // + e, err := servicecfg.NewEnvironment(logger, v.Sub("service")) + if err != nil { + logger.Log(level.Key(), level.ErrorValue(), logging.MessageKey(), "Unable to initialize service discovery environment", logging.ErrorKey(), err) + return 4 + } + + if e != nil { + defer e.Close() + logger.Log(level.Key(), level.InfoValue(), "configurationFile", v.ConfigFileUsed()) + e.Register() + + _, err = monitor.New( + monitor.WithLogger(logger), + monitor.WithFilter(monitor.NewNormalizeFilter(e.DefaultScheme())), + monitor.WithEnvironment(e), + monitor.WithListeners( + monitor.NewMetricsListener(metricsRegistry), + monitor.NewRegistrarListener(logger, e, true), + ), + ) + + if err != nil { + if err.Error() != "No instances to monitor" { + logger.Log(level.Key(), level.ErrorValue(), logging.MessageKey(), "Unable to start service discovery monitor", logging.ErrorKey(), err) + return 5 + } + } + } else { + logger.Log(level.Key(), level.InfoValue(), logging.MessageKey(), "no service discovery configured") + } + // Attempt to obtain the current listener list from current system without having to wait for listener reregistration. debugLog.Log(messageKey, "Attempting to obtain current listener list from source", "source", v.GetString("start.apiPath")) diff --git a/src/glide.lock b/src/glide.lock index 7e6c4a55..bc193337 100644 --- a/src/glide.lock +++ b/src/glide.lock @@ -1,6 +1,8 @@ hash: 8e0b5dc0f4fcee573e27644aa4b665502fecb68c941dad21430d3f491ee8519d updated: 2019-02-21T10:14:46.1291513-08:00 imports: +- name: github.com/armon/go-metrics + version: 783273d703149aaeb9897cf58613d5af48861c25 - name: github.com/aws/aws-sdk-go version: 7be45195c3af1b54a609812f90c05a7e492e2491 subpackages: @@ -33,6 +35,8 @@ imports: version: 3a771d992973f24aa725d07868b467d1ddfceafb subpackages: - quantile +- name: github.com/billhathaway/consistentHash + version: addea16d2229dba874111898b45be7f4a78af631 - name: github.com/c9s/goprocinfo version: 19cb9f127a9c8d2034cf59ccb683cdb94b9deb6c subpackages: @@ -40,6 +44,8 @@ imports: - name: github.com/Comcast/webpa-common version: ee36b7e7561c779aa65a66fbef35b46720486987 subpackages: + - capacitor + - clock - concurrent - convey - convey/conveyhttp @@ -53,6 +59,11 @@ imports: - secure/key - semaphore - server + - service + - service/consul + - service/monitor + - service/servicecfg + - service/zk - types - webhook - webhook/aws @@ -62,6 +73,7 @@ imports: - xhttp - xlistener - xmetrics + - xviper - name: github.com/davecgh/go-spew version: 8991bc29aa16c548c550c7ff78260e27b9ab7c73 subpackages: @@ -88,6 +100,10 @@ imports: - metrics/prometheus - metrics/provider - metrics/statsd + - sd + - sd/consul + - sd/internal/instance + - sd/zk - transport/http - util/conn - name: github.com/go-logfmt/logfmt @@ -102,6 +118,20 @@ imports: version: 53c1911da2b537f792e7cafcb446b05ffe33b996 - name: github.com/gorilla/websocket version: ea4d1f681babbce9545c9c5f3d5194a789c89f5b +- name: github.com/hashicorp/consul + version: 9a494b5fb9c86180a5702e29c485df1507a47198 + subpackages: + - api +- name: github.com/hashicorp/go-cleanhttp + version: d5fe4b57a186c716b0e00b8c301cbd9b4182694d +- name: github.com/hashicorp/go-immutable-radix + version: 7f3cd4390caab3250a57f30efdb2a65dd7649ecf +- name: github.com/hashicorp/go-rootcerts + version: 6bb64b370b90e7ef1fa532be9e591a81c3493e00 +- name: github.com/hashicorp/golang-lru + version: 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 + subpackages: + - simplelru - name: github.com/hashicorp/hcl version: ef8a98b0bbce4a65b5aa4c368430a80ddc533168 subpackages: @@ -114,6 +144,10 @@ imports: - json/parser - json/scanner - json/token +- name: github.com/hashicorp/serf + version: 80ab48778deee28e4ea2dc4ef1ebb2c5f4063996 + subpackages: + - coordinate - name: github.com/influxdata/influxdb version: 48797873ee24fc1dcb5a63f23474d3210f6d68c5 subpackages: @@ -136,6 +170,8 @@ imports: - pbutil - name: github.com/miekg/dns version: ba6747e8a94115e9dc7738afb87850687611df1b +- name: github.com/mitchellh/go-homedir + version: b8bc1bf767474819792c23f32d8286a45736f1c6 - name: github.com/mitchellh/mapstructure version: bb74f1db0675b241733089d5a1faa5dd8b0ef57b - name: github.com/pelletier/go-toml @@ -166,6 +202,10 @@ imports: - internal/util - nfs - xfs +- name: github.com/samuel/go-zookeeper + version: c4fab1ac1bec58281ad0667dc3f0907a9476ac47 + subpackages: + - zk - name: github.com/satori/go.uuid version: f58768cc1a7a7e77a3bd49e98cdd21419399b6a3 - name: github.com/SermoDigital/jose @@ -174,6 +214,8 @@ imports: - crypto - jws - jwt +- name: github.com/spaolacci/murmur3 + version: 0d12bf811670bf6a1a63828dfbd003eded177fce - name: github.com/spf13/afero version: 787d034dfe70e44075ccc060d346146ef53270ad subpackages: