Fix RequestLogCollectorJob sometimes not properly shutting down

This commit is contained in:
2023-05-28 12:31:14 +02:00
parent 624c613bd1
commit efaad3f97c
5 changed files with 26 additions and 14 deletions

View File

@@ -24,7 +24,7 @@ func NewDeliveryRetryJob(app *logic.Application) *DeliveryRetryJob {
name: "DeliveryRetryJob",
isRunning: syncext.NewAtomicBool(false),
isStarted: false,
sigChannel: make(chan string),
sigChannel: make(chan string, 1),
}
}
@@ -45,7 +45,9 @@ func (j *DeliveryRetryJob) Start() error {
func (j *DeliveryRetryJob) Stop() {
log.Info().Msg(fmt.Sprintf("Stopping Job [%s]", j.name))
syncext.WriteNonBlocking(j.sigChannel, "stop")
if !syncext.WriteNonBlocking(j.sigChannel, "stop") {
log.Error().Msg(fmt.Sprintf("Failed to send Stop-Signal to Job [%s]", j.name))
}
j.isRunning.Wait(false)
log.Info().Msg(fmt.Sprintf("Stopped Job [%s]", j.name))
}