mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
common/httpserver: do not connect to Redis before starting component
We need to be able to dump the configuration without redis being present.
This commit is contained in:
@@ -47,7 +47,6 @@ type Dependencies struct {
|
|||||||
|
|
||||||
// New creates a new HTTP component.
|
// New creates a new HTTP component.
|
||||||
func New(r *reporter.Reporter, configuration Configuration, dependencies Dependencies) (*Component, error) {
|
func New(r *reporter.Reporter, configuration Configuration, dependencies Dependencies) (*Component, error) {
|
||||||
var err error
|
|
||||||
c := Component{
|
c := Component{
|
||||||
r: r,
|
r: r,
|
||||||
d: &dependencies,
|
d: &dependencies,
|
||||||
@@ -58,10 +57,6 @@ func New(r *reporter.Reporter, configuration Configuration, dependencies Depende
|
|||||||
}
|
}
|
||||||
c.initMetrics()
|
c.initMetrics()
|
||||||
c.d.Daemon.Track(&c.t, "common/http")
|
c.d.Daemon.Track(&c.t, "common/http")
|
||||||
c.cacheStore, err = configuration.Cache.Config.New()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
c.GinRouter.Use(gin.Recovery())
|
c.GinRouter.Use(gin.Recovery())
|
||||||
c.AddHandler("/api/", c.GinRouter)
|
c.AddHandler("/api/", c.GinRouter)
|
||||||
if configuration.Profiler {
|
if configuration.Profiler {
|
||||||
@@ -109,6 +104,13 @@ func (c *Component) Start() error {
|
|||||||
if c.config.Listen == "" {
|
if c.config.Listen == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.r.Info().Msg("starting HTTP component")
|
||||||
|
var err error
|
||||||
|
c.cacheStore, err = c.config.Cache.Config.New()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
server := &http.Server{Handler: c.mux}
|
server := &http.Server{Handler: c.mux}
|
||||||
|
|
||||||
// Most of the time, if we have an error, it's here!
|
// Most of the time, if we have an error, it's here!
|
||||||
|
|||||||
Reference in New Issue
Block a user