This commit is contained in:
tcq 2023-04-27 09:16:13 +08:00
parent 63b8502bbb
commit 888ab96580
2 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,7 @@ func Service(conf *Config) *Config {
} }
go func() { go func() {
router := gin.New() router := gin.New()
router.Use(gin.Logger(), gin.Recovery())
routerSetup(router, &conf.RootPath) routerSetup(router, &conf.RootPath)
if conf.Ssl { if conf.Ssl {

View File

@ -21,7 +21,7 @@ func main() {
consul.Init(nil) consul.Init(nil)
gin.Service(&gin.Config{ gin.Service(&gin.Config{
RootPath: `/`, RootPath: `/demo1`,
Addr: *addr, Addr: *addr,
Port: *port, Port: *port,
}) })
@ -37,6 +37,13 @@ func main() {
<-c <-c
_, cancel := context.WithTimeout(context.Background(), 15*time.Second) _, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel() defer cancel()
//取消注册
err := consul.DeRegister(*appname, *addr, 8082)
if err != nil {
fmt.Println("Error: ", err)
}
fmt.Println("campus-demo1 service shutting down") fmt.Println("campus-demo1 service shutting down")
os.Exit(0) os.Exit(0)
} }