traefik/server/server_signals.go

39 lines
721 B
Go
Raw Normal View History

// +build !windows
package server
import (
"os/signal"
"syscall"
"github.com/containous/traefik/log"
)
2017-11-24 18:18:03 +00:00
func (s *Server) configureSignals() {
2018-03-14 12:14:03 +00:00
signal.Notify(s.signals, syscall.SIGUSR1)
}
2018-09-06 12:24:03 +00:00
func (s *Server) listenSignals(stop chan bool) {
for {
2018-09-06 12:24:03 +00:00
select {
case <-stop:
return
case sig := <-s.signals:
switch sig {
case syscall.SIGUSR1:
log.Infof("Closing and re-opening log files for rotation: %+v", sig)
2018-09-06 12:24:03 +00:00
if s.accessLoggerMiddleware != nil {
if err := s.accessLoggerMiddleware.Rotate(); err != nil {
log.Errorf("Error rotating access log: %v", err)
}
}
2018-09-06 12:24:03 +00:00
if err := log.RotateFile(); err != nil {
log.Errorf("Error rotating traefik log: %v", err)
}
}
}
}
}