diff --git a/gin/gin.go b/gin/gin.go index 3c56504..910db7c 100644 --- a/gin/gin.go +++ b/gin/gin.go @@ -24,6 +24,7 @@ func Service(conf *Config) *Config { } go func() { router := gin.New() + router.Use(gin.Logger(), gin.Recovery()) routerSetup(router, &conf.RootPath) if conf.Ssl { diff --git a/main.go b/main.go index 33fdf9f..e62f2b4 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ func main() { consul.Init(nil) gin.Service(&gin.Config{ - RootPath: `/`, + RootPath: `/demo1`, Addr: *addr, Port: *port, }) @@ -37,6 +37,13 @@ func main() { <-c _, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() + + //取消注册 + err := consul.DeRegister(*appname, *addr, 8082) + if err != nil { + fmt.Println("Error: ", err) + } + fmt.Println("campus-demo1 service shutting down") os.Exit(0) }