Wait for both api and agent chans if necessary when daemonize is false or running on windows (#2155)
This commit is contained in:
parent
0279e549bd
commit
1e018bdaf8
|
@ -356,14 +356,24 @@ func Serve(cConfig *csconfig.Config, apiReady chan bool, agentReady chan bool) e
|
||||||
return HandleSignals(cConfig)
|
return HandleSignals(cConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
waitChans := make([]<-chan struct{}, 0)
|
||||||
select {
|
|
||||||
case <-apiTomb.Dead():
|
if !cConfig.DisableAgent {
|
||||||
|
waitChans = append(waitChans, crowdsecTomb.Dead())
|
||||||
|
}
|
||||||
|
|
||||||
|
if !cConfig.DisableAPI {
|
||||||
|
waitChans = append(waitChans, apiTomb.Dead())
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ch := range waitChans {
|
||||||
|
<-ch
|
||||||
|
switch ch {
|
||||||
|
case apiTomb.Dead():
|
||||||
log.Infof("api shutdown")
|
log.Infof("api shutdown")
|
||||||
return nil
|
case crowdsecTomb.Dead():
|
||||||
case <-crowdsecTomb.Dead():
|
|
||||||
log.Infof("crowdsec shutdown")
|
log.Infof("crowdsec shutdown")
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue