From 825f65f79ee4c8934961a7b040f7d42a42f7e946 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Wed, 20 Dec 2023 16:20:36 +0300 Subject: [PATCH] [#873] node: Start metrics and pprof as soon as possible Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-node/httpcomponent.go | 21 +++++++++------------ cmd/frostfs-node/worker.go | 9 --------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/cmd/frostfs-node/httpcomponent.go b/cmd/frostfs-node/httpcomponent.go index 6e8fa8f2c..373a5e5c8 100644 --- a/cmd/frostfs-node/httpcomponent.go +++ b/cmd/frostfs-node/httpcomponent.go @@ -36,21 +36,19 @@ func (cmp *httpComponent) init(c *cfg) { cmp.shutdownDur, ), ) + c.wg.Add(1) + go func() { + defer c.wg.Done() + + c.log.Info(logs.FrostFSNodeStartListeningEndpoint, + zap.String("service", cmp.name), + zap.String("endpoint", cmp.address)) + fatalOnErr(srv.Serve()) + }() c.closers = append(c.closers, closer{ cmp.name, func() { stopAndLog(c, cmp.name, srv.Shutdown) }, }) - c.workers = append(c.workers, worker{ - cmp.name, - func(ctx context.Context) { - runAndLog(ctx, c, cmp.name, false, func(context.Context, *cfg) { - c.log.Info(logs.FrostFSNodeStartListeningEndpoint, - zap.String("service", cmp.name), - zap.String("endpoint", cmp.address)) - fatalOnErr(srv.Serve()) - }) - }, - }) } func (cmp *httpComponent) reload(ctx context.Context) error { @@ -64,7 +62,6 @@ func (cmp *httpComponent) reload(ctx context.Context) error { } // Cleanup delCloser(cmp.cfg, cmp.name) - delWorker(cmp.cfg, cmp.name) // Init server with new parameters cmp.init(cmp.cfg) // Start worker diff --git a/cmd/frostfs-node/worker.go b/cmd/frostfs-node/worker.go index bea235c48..c5649073b 100644 --- a/cmd/frostfs-node/worker.go +++ b/cmd/frostfs-node/worker.go @@ -30,15 +30,6 @@ func startWorker(ctx context.Context, c *cfg, wrk worker) { }(wrk) } -func delWorker(c *cfg, name string) { - for i, worker := range c.workers { - if worker.name == name { - c.workers = append(c.workers[:i], c.workers[i+1:]...) - return - } - } -} - func getWorker(c *cfg, name string) *worker { for _, wrk := range c.workers { if wrk.name == name {