wheat-cache/pkg/util/server/os.go

30 lines
479 B
Go
Raw Normal View History

2021-10-16 22:51:28 +08:00
package server
import (
"os"
"os/signal"
"syscall"
2021-11-02 14:45:08 +08:00
"gitee.com/wheat-os/wheatCache/pkg/logx"
2021-10-16 22:51:28 +08:00
"google.golang.org/grpc"
)
func ElegantExitServer(s *grpc.Server) {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT)
go func() {
select {
case <-c:
s.Stop()
msg := `
|-------Wheat tools---------|
| see you next time |
|thank you for your efforts |
|---------------------------|
`
logx.Infoln(msg)
}
}()
}