From db56fadc0d169318f54005c9d2c93573e119e015 Mon Sep 17 00:00:00 2001 From: alessandromazza Date: Wed, 25 Sep 2024 18:39:13 +0200 Subject: [PATCH] fix: terminate process once it completes all the work --- cmd/replayor/main.go | 2 +- packages/replayor/service.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/replayor/main.go b/cmd/replayor/main.go index bd5388c..3713659 100644 --- a/cmd/replayor/main.go +++ b/cmd/replayor/main.go @@ -58,6 +58,6 @@ func Main() cliapp.LifecycleAction { } statsRecorder := stats.NewStoredStats(s, logger) - return replayor.NewService(c, statsRecorder, cfg, logger), nil + return replayor.NewService(c, statsRecorder, cfg, logger, close), nil } } diff --git a/packages/replayor/service.go b/packages/replayor/service.go index 32ba91d..4bad868 100644 --- a/packages/replayor/service.go +++ b/packages/replayor/service.go @@ -24,14 +24,16 @@ type Service struct { stats stats.Stats cfg config.ReplayorConfig log log.Logger + close context.CancelCauseFunc } -func NewService(c clients.Clients, s stats.Stats, cfg config.ReplayorConfig, l log.Logger) *Service { +func NewService(c clients.Clients, s stats.Stats, cfg config.ReplayorConfig, l log.Logger, close context.CancelCauseFunc) *Service { return &Service{ clients: c, stats: s, cfg: cfg, log: l, + close: close, } } @@ -98,6 +100,8 @@ func (r *Service) Start(ctx context.Context) error { benchmark := NewBenchmark(r.clients, r.cfg.RollupConfig, r.log, strategy, r.stats, currentBlock, uint64(r.cfg.BlockCount), r.cfg.BenchmarkOpcodes, r.cfg.ComputeStorageDiffs) benchmark.Run(cCtx) + // shutdown the whole application + r.close(nil) return nil }