代码拉取完成,页面将自动刷新
//go:build !windows
// +build !windows
package yomo
import (
"os"
"os/signal"
"runtime"
"syscall"
"github.com/yomorun/yomo/core"
"github.com/yomorun/yomo/core/ylog"
)
// initialize when zipper running as server. support inspection:
// - `kill -SIGUSR1 <pid>` inspect state()
// - `kill -SIGTERM <pid>` graceful shutdown
// - `kill -SIGUSR2 <pid>` inspect golang GC
func waitSignalForShutdownServer(server *core.Server) {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM, syscall.SIGUSR2, syscall.SIGUSR1, syscall.SIGINT)
ylog.Info("Listening SIGUSR1, SIGUSR2, SIGTERM/SIGINT...")
for p1 := range c {
ylog.Debug("Received signal", "signal", p1)
if p1 == syscall.SIGTERM || p1 == syscall.SIGINT {
ylog.Debug("graceful shutting down ...", "sign", p1)
// waiting for the server to finish processing the current request
server.Close()
os.Exit(0)
} else if p1 == syscall.SIGUSR2 {
var m runtime.MemStats
runtime.ReadMemStats(&m)
ylog.Debug("runtime stats", "gc_nums", m.NumGC)
} else if p1 == syscall.SIGUSR1 {
statsToLogger(server)
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。