-
Notifications
You must be signed in to change notification settings - Fork 128
/
zipper_windows.go
31 lines (27 loc) 路 741 Bytes
/
zipper_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//go:build windows
// +build windows
package yomo
import (
"os"
"os/signal"
"syscall"
"github.com/yomorun/yomo/core"
"github.com/yomorun/yomo/core/ylog"
"github.com/yomorun/yomo/pkg/trace"
)
// initialize when zipper running as server. support inspection:
// - `kill -SIGTERM <pid>` graceful shutdown
func waitSignalForShutdownServer(server *core.Server) {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT)
ylog.Info("Listening SIGTERM/SIGINT...")
for p1 := range c {
ylog.Debug("Received signal", "signal", p1)
if p1 == syscall.SIGTERM || p1 == syscall.SIGINT {
server.Close()
trace.ShutdownTracerProvider()
ylog.Debug("graceful shutting down ...", "sign", p1)
os.Exit(0)
}
}
}