package main import ( "context" "os" "os/signal" "time" "github.com/sirupsen/logrus" "myschools.me/xixi.xv/hello/gin" ) func main() { gin.Service(&gin.Config{ RootPath: "hello", Addr: "0.0.0.0", Port: 8080, Ssl: false, }) logrus.WithFields(logrus.Fields{ "func": "main", }).Info("service runing ...") // 服务停止相应 c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) <-c _, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() logrus.WithFields(logrus.Fields{ "func": "main", }).Info("service shutting down") os.Exit(0) }