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:
Vincent Bernat
2025-09-16 21:42:13 +02:00
parent 327a78cc1c
commit 0db8f43b10

View File

@@ -47,7 +47,6 @@ type Dependencies struct {
// New creates a new HTTP component.
func New(r *reporter.Reporter, configuration Configuration, dependencies Dependencies) (*Component, error) {
var err error
c := Component{
r: r,
d: &dependencies,
@@ -58,10 +57,6 @@ func New(r *reporter.Reporter, configuration Configuration, dependencies Depende
}
c.initMetrics()
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.AddHandler("/api/", c.GinRouter)
if configuration.Profiler {
@@ -109,6 +104,13 @@ func (c *Component) Start() error {
if c.config.Listen == "" {
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}
// Most of the time, if we have an error, it's here!