-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Description
发信号
kill -SIGHUP 12068
之后报这个错误
jsonrpc2.go:201: ERROR: error in JSONRPC server: *errors.errorString http: Server closed
虽然可以成功起动一个新进程来监听端口,但是这个错误是正常的吗?
type Server struct {
engine *server.Server
apiRouter *Router
}
func (s *Server) Start() {
s.apiRouter.With(s.engine)
s.engine.Serve("tcp", "localhost:8972")
//s.engine.Serve("reuseport", "localhost:8972")
}
func (s *Server) StartShutdownListener() {
go func(s *Server) {
log.Println("server pid:", os.Getpid())
// channel to receive notifications of SIGTERM and SIGHUP
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGTERM, syscall.SIGHUP)
// handle signal SIGTERM and SIGHUP
switch <-ch {
case syscall.SIGTERM:
s.engine.RegisterOnShutdown(func(s *server.Server) {
log.Println("graceful shutdown...")
})
s.engine.Shutdown(context.Background())
case syscall.SIGHUP:
s.engine.Restart(context.Background())
s.engine.RegisterOnRestart(func(s *server.Server) {
log.Println("graceful restart...")
})
s.engine.Restart(context.Background())
}
}(s)
}
go版本:
go version go1.20.1 linux/amd64
rpcx : v1.8.24
@smallnest 辛苦看一下 感谢
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels