Skip to content

Commit

Permalink
Merge pull request #106 from kcajmagic/sendStatus
Browse files Browse the repository at this point in the history
added consul registration
  • Loading branch information
schmidtw authored Feb 22, 2019
2 parents 1d9ea83 + 399d299 commit 2a117f4
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/caduceus/caduceus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"))
Expand Down
42 changes: 42 additions & 0 deletions src/glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a117f4

Please sign in to comment.