[#873] node: Start metrics and pprof as soon as possible

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-12-20 16:20:36 +03:00 committed by Evgenii Stratonikov
parent b1eab1de54
commit 825f65f79e
2 changed files with 9 additions and 21 deletions

View file

@ -36,20 +36,18 @@ func (cmp *httpComponent) init(c *cfg) {
cmp.shutdownDur, cmp.shutdownDur,
), ),
) )
c.closers = append(c.closers, closer{ c.wg.Add(1)
cmp.name, go func() {
func() { stopAndLog(c, cmp.name, srv.Shutdown) }, defer c.wg.Done()
})
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, c.log.Info(logs.FrostFSNodeStartListeningEndpoint,
zap.String("service", cmp.name), zap.String("service", cmp.name),
zap.String("endpoint", cmp.address)) zap.String("endpoint", cmp.address))
fatalOnErr(srv.Serve()) fatalOnErr(srv.Serve())
}) }()
}, c.closers = append(c.closers, closer{
cmp.name,
func() { stopAndLog(c, cmp.name, srv.Shutdown) },
}) })
} }
@ -64,7 +62,6 @@ func (cmp *httpComponent) reload(ctx context.Context) error {
} }
// Cleanup // Cleanup
delCloser(cmp.cfg, cmp.name) delCloser(cmp.cfg, cmp.name)
delWorker(cmp.cfg, cmp.name)
// Init server with new parameters // Init server with new parameters
cmp.init(cmp.cfg) cmp.init(cmp.cfg)
// Start worker // Start worker

View file

@ -30,15 +30,6 @@ func startWorker(ctx context.Context, c *cfg, wrk worker) {
}(wrk) }(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 { func getWorker(c *cfg, name string) *worker {
for _, wrk := range c.workers { for _, wrk := range c.workers {
if wrk.name == name { if wrk.name == name {