demo1
This commit is contained in:
parent
63b8502bbb
commit
888ab96580
|
|
@ -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 {
|
||||||
|
|
|
||||||
9
main.go
9
main.go
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue