File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
"github.com/onflow/flow-go/fvm/evm"
15
15
flowGo "github.com/onflow/flow-go/model/flow"
16
16
"github.com/onflow/flow-go/module/component"
17
+ "github.com/onflow/flow-go/module/irrecoverable"
17
18
flowMetrics "github.com/onflow/flow-go/module/metrics"
18
19
gethTypes "github.com/onflow/go-ethereum/core/types"
19
20
"github.com/rs/zerolog"
@@ -368,13 +369,35 @@ func (b *Bootstrap) StartMetricsServer(ctx context.Context) error {
368
369
369
370
b .metrics = flowMetrics .NewServer (b .logger , uint (b .config .MetricsPort ))
370
371
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
+
371
393
return nil
372
394
}
373
395
374
396
func (b * Bootstrap ) StopMetricsServer () {
375
397
if b .metrics == nil {
376
398
return
377
399
}
400
+ <- b .metrics .Done ()
378
401
b .logger .Warn ().Msg ("shutting down metrics server" )
379
402
}
380
403
You can’t perform that action at this time.
0 commit comments