package main
import (
"github.com/fvbock/endless"
"github.com/gin-gonic/gin"
"log"
)
func main() {
router := gin.Default()
router.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{"message": "pong"})
})
log.Printf("Starting Server")
server := endless.NewServer(":8080", router)
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)
}
log.Printf("Server on %d stopped", syscall.Getpid())
}
标签:log,err,demo,Printf,Server,不停,gin,endless
From: https://www.cnblogs.com/0x1cc4/p/18127387