1 Star 0 Fork 0

东海苍月/traefik

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
server_signals.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Ludovic Fernandez 提交于 2017-11-24 19:18 . Change server receiver name.
// +build !windows
package server
import (
"os/signal"
"syscall"
"time"
"github.com/containous/traefik/log"
)
func (s *Server) configureSignals() {
signal.Notify(s.signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)
}
func (s *Server) listenSignals() {
for {
sig := <-s.signals
switch sig {
case syscall.SIGUSR1:
log.Infof("Closing and re-opening log files for rotation: %+v", sig)
if s.accessLoggerMiddleware != nil {
if err := s.accessLoggerMiddleware.Rotate(); err != nil {
log.Errorf("Error rotating access log: %s", err)
}
}
if err := log.RotateFile(); err != nil {
log.Errorf("Error rotating traefik log: %s", err)
}
default:
log.Infof("I have to go... %+v", sig)
reqAcceptGraceTimeOut := time.Duration(s.globalConfiguration.LifeCycle.RequestAcceptGraceTimeout)
if reqAcceptGraceTimeOut > 0 {
log.Infof("Waiting %s for incoming requests to cease", reqAcceptGraceTimeOut)
time.Sleep(reqAcceptGraceTimeOut)
}
log.Info("Stopping server gracefully")
s.Stop()
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dhcy/traefik.git
git@gitee.com:dhcy/traefik.git
dhcy
traefik
traefik
v1.5.0-rc4

搜索帮助