2021-09-16 09:16:07 +02:00
|
|
|
//go:build !windows
|
2017-08-11 11:04:58 +01:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2020-02-03 17:56:04 +01:00
|
|
|
"context"
|
2017-08-11 11:04:58 +01:00
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
|
2022-11-21 18:36:05 +01:00
|
|
|
"github.com/rs/zerolog/log"
|
2017-08-11 11:04:58 +01:00
|
|
|
)
|
|
|
|
|
2017-11-24 19:18:03 +01:00
|
|
|
func (s *Server) configureSignals() {
|
2018-03-14 13:14:03 +01:00
|
|
|
signal.Notify(s.signals, syscall.SIGUSR1)
|
2017-08-11 11:04:58 +01:00
|
|
|
}
|
|
|
|
|
2020-02-03 17:56:04 +01:00
|
|
|
func (s *Server) listenSignals(ctx context.Context) {
|
2017-08-11 11:04:58 +01:00
|
|
|
for {
|
2018-09-06 14:24:03 +02:00
|
|
|
select {
|
2020-02-03 17:56:04 +01:00
|
|
|
case <-ctx.Done():
|
2018-09-06 14:24:03 +02:00
|
|
|
return
|
|
|
|
case sig := <-s.signals:
|
2019-02-05 17:10:03 +01:00
|
|
|
if sig == syscall.SIGUSR1 {
|
2022-11-21 18:36:05 +01:00
|
|
|
log.Info().Msgf("Closing and re-opening log files for rotation: %+v", sig)
|
2017-08-11 11:04:58 +01:00
|
|
|
|
2024-01-30 16:28:05 +01:00
|
|
|
if err := s.observabilityMgr.RotateAccessLogs(); err != nil {
|
|
|
|
log.Error().Err(err).Msg("Error rotating access log")
|
2017-08-11 11:04:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|