Timeout on shutdown while waiting for events to be flushed (#2423)
This commit is contained in:
parent
afeb541eac
commit
caaed7c515
|
@ -141,12 +141,24 @@ func ShutdownCrowdsecRoutines() error {
|
|||
time.Sleep(1 * time.Second) // ugly workaround for now
|
||||
outputsTomb.Kill(nil)
|
||||
|
||||
if err := outputsTomb.Wait(); err != nil {
|
||||
log.Warningf("Ouputs returned error : %s", err)
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
done <- outputsTomb.Wait()
|
||||
}()
|
||||
|
||||
// wait for outputs to finish, max 3 seconds
|
||||
select {
|
||||
case err := <-done:
|
||||
if err != nil {
|
||||
log.Warningf("Outputs returned error : %s", err)
|
||||
reterr = err
|
||||
}
|
||||
|
||||
log.Debugf("outputs are done")
|
||||
case <-time.After(3 * time.Second):
|
||||
// this can happen if outputs are stuck in a http retry loop
|
||||
log.Warningf("Outputs didn't finish in time, some events may have not been flushed")
|
||||
}
|
||||
|
||||
// He's dead, Jim.
|
||||
crowdsecTomb.Kill(nil)
|
||||
|
||||
|
|
Loading…
Reference in a new issue