blog
blog copied to clipboard
posts/go/gin/2018-03-15-reload-http/
windows 下无法使用
方案一是优雅的重启 方案二是优雅的关闭 并非替代关系
go语言windows平台兼容性好像有很多的问题, 比如net包里有很多在windows平台都没有实现
很棒
挺不错
Windows无法安装包错
❯ go get -u github.com/fvbock/endless
# github.com/fvbock/endless
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:64:3: undefined: syscall.SIGUSR1
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:65:3: undefined: syscall.SIGUSR2
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:68:3: undefined: syscall.SIGTSTP
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:111:5: undefined: syscall.SIGUSR1
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:112:5: undefined: syscall.SIGUSR2
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:115:5: undefined: syscall.SIGTSTP
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:119:5: undefined: syscall.SIGUSR1
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:120:5: undefined: syscall.SIGUSR2
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:123:5: undefined: syscall.SIGTSTP
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:224:3: undefined: syscall.Kill
C:\Users\pro91\go\pkg\mod\github.com\fvbock\[email protected]\endless.go:224:3: too many errors
❯ go version
go version go1.17.7 windows/amd64
百度了下解决方法win下没有 16-18的信号: https://blog.csdn.net/qq_28466271/article/details/116521955
项目名称怎么回事 一会是go-gin-example 一会变gin-blog???????
endless报错未定义信号量 windows下解决方案https://learnku.com/articles/51696
可以将优雅重启和优雅关闭结合在一块吗?像这样:
endless.DefaultReadTimeOut = setting.ReadTimeout
endless.DefaultWriteTimeOut = setting.WriteTimeout
endless.DefaultMaxHeaderBytes = 1 << 20
endPoint := fmt.Sprintf(":%d", setting.HTTPPort)
server := endless.NewServer(endPoint, routers.InitRouter())
server.BeforeBegin = func(add string) {
log.Printf("Actual pid is %d", syscall.Getpid())
}
err := server.ListenAndServe()
if err != nil {
log.Printf("Server err: %v", err)
}
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt)
<- quit
log.Println("Shutdown Server ...")
ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second)
defer cancel()
if err := s.Shutdown(ctx); err != nil {
log.Fatal("Server Shutdown:", err)
}
log.Println("Server exiting")