File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
1414 "github.com/onflow/flow-go/fvm/evm"
1515 flowGo "github.com/onflow/flow-go/model/flow"
1616 "github.com/onflow/flow-go/module/component"
17+ "github.com/onflow/flow-go/module/irrecoverable"
1718 flowMetrics "github.com/onflow/flow-go/module/metrics"
1819 gethTypes "github.com/onflow/go-ethereum/core/types"
1920 "github.com/rs/zerolog"
@@ -368,13 +369,35 @@ func (b *Bootstrap) StartMetricsServer(ctx context.Context) error {
368369
369370 b .metrics = flowMetrics .NewServer (b .logger , uint (b .config .MetricsPort ))
370371
372+ // this logic is needed since the metric server is a component.
373+ // we need to start and stop it manually here.
374+
375+ ictx , errCh := irrecoverable .WithSignaler (ctx )
376+ b .metrics .Start (ictx )
377+ <- b .metrics .Ready ()
378+ select {
379+ case err := <- errCh :
380+ // there might be an error already if the startup failed
381+ return err
382+ default :
383+ }
384+
385+ go func () {
386+ err := <- errCh
387+ if err != nil {
388+ b .logger .Err (err ).Msg ("error in metrics server" )
389+ panic (err )
390+ }
391+ }()
392+
371393 return nil
372394}
373395
374396func (b * Bootstrap ) StopMetricsServer () {
375397 if b .metrics == nil {
376398 return
377399 }
400+ <- b .metrics .Done ()
378401 b .logger .Warn ().Msg ("shutting down metrics server" )
379402}
380403
You can’t perform that action at this time.
0 commit comments