Exit syslog acquis only after server is dead (#1288)
This commit is contained in:
parent
a300d5818f
commit
c3dbe0080c
|
@ -61,7 +61,7 @@ func (s *SyslogServer) StartServer() *tomb.Tomb {
|
|||
for {
|
||||
select {
|
||||
case <-t.Dying():
|
||||
s.Logger.Info("syslog server tomb is dying")
|
||||
s.Logger.Info("Syslog server tomb is dying")
|
||||
err := s.KillServer()
|
||||
return err
|
||||
default:
|
||||
|
@ -92,5 +92,6 @@ func (s *SyslogServer) KillServer() error {
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "could not close UDP connection")
|
||||
}
|
||||
close(s.channel)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -180,15 +180,15 @@ func (s *SyslogSource) buildLogFromSyslog(ts *time.Time, hostname *string,
|
|||
}
|
||||
|
||||
func (s *SyslogSource) handleSyslogMsg(out chan types.Event, t *tomb.Tomb, c chan syslogserver.SyslogMessage) error {
|
||||
killed := false
|
||||
for {
|
||||
select {
|
||||
case <-t.Dying():
|
||||
if !killed {
|
||||
s.logger.Info("Syslog datasource is dying")
|
||||
s.serverTomb.Kill(nil)
|
||||
return s.serverTomb.Wait()
|
||||
case <-s.serverTomb.Dying():
|
||||
s.logger.Info("Syslog server is dying, exiting")
|
||||
return nil
|
||||
killed = true
|
||||
}
|
||||
case <-s.serverTomb.Dead():
|
||||
s.logger.Info("Syslog server has exited")
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue