Skip to content

Commit 68087a0

Browse files
committed
terminate when poller or committer exit
1 parent eea71f4 commit 68087a0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

internal/orchestrator/orchestrator.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ func (o *Orchestrator) Start() {
6767

6868
poller := NewPoller(o.rpc, o.storage, WithPollerWorkModeChan(pollerWorkModeChan))
6969
poller.Start(ctx)
70+
7071
log.Info().Msg("Poller completed")
72+
// If the poller is terminated, cancel the orchestrator
73+
o.cancel()
7174
}()
7275
}
7376

@@ -77,6 +80,8 @@ func (o *Orchestrator) Start() {
7780
defer o.wg.Done()
7881
failureRecoverer := NewFailureRecoverer(o.rpc, o.storage)
7982
failureRecoverer.Start(ctx)
83+
84+
log.Info().Msg("Failure recoverer completed")
8085
}()
8186
}
8287

@@ -90,6 +95,10 @@ func (o *Orchestrator) Start() {
9095
validator := NewValidator(o.rpc, o.storage)
9196
committer := NewCommitter(o.rpc, o.storage, WithCommitterWorkModeChan(committerWorkModeChan), WithValidator(validator))
9297
committer.Start(ctx)
98+
99+
// If the committer is terminated, cancel the orchestrator
100+
log.Info().Msg("Committer completed")
101+
o.cancel()
93102
}()
94103
}
95104

@@ -99,13 +108,17 @@ func (o *Orchestrator) Start() {
99108
defer o.wg.Done()
100109
reorgHandler := NewReorgHandler(o.rpc, o.storage)
101110
reorgHandler.Start(ctx)
111+
112+
log.Info().Msg("Reorg handler completed")
102113
}()
103114
}
104115

105116
o.wg.Add(1)
106117
go func() {
107118
defer o.wg.Done()
108119
workModeMonitor.Start(ctx)
120+
121+
log.Info().Msg("Work mode monitor completed")
109122
}()
110123

111124
// The chain tracker is always running
@@ -114,11 +127,12 @@ func (o *Orchestrator) Start() {
114127
defer o.wg.Done()
115128
chainTracker := NewChainTracker(o.rpc)
116129
chainTracker.Start(ctx)
117-
}()
118130

119-
o.wg.Wait()
131+
log.Info().Msg("Chain tracker completed")
132+
}()
120133

121134
// Waiting for all goroutines to complete
135+
o.wg.Wait()
122136

123137
if err := o.storage.Close(); err != nil {
124138
log.Error().Err(err).Msg("Error closing storage connections")

0 commit comments

Comments
 (0)