luoyangwei 1 rok temu
rodzic
commit
7d8e643468
3 zmienionych plików z 8 dodań i 8 usunięć
  1. 1 0
      go.mod
  2. 2 0
      go.sum
  3. 5 8
      websocket.go

+ 1 - 0
go.mod

@@ -17,6 +17,7 @@ require (
 )
 
 require (
+	github.com/DeanThompson/ginpprof v0.0.0-20201112072838-007b1e56b2e1 // indirect
 	github.com/bytedance/sonic v1.10.2 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 	github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect

+ 2 - 0
go.sum

@@ -1,3 +1,5 @@
+github.com/DeanThompson/ginpprof v0.0.0-20201112072838-007b1e56b2e1 h1:IIOiH2YkFyyHCImuX7YWlHpc7wHZTQVxZwADs5jfggQ=
+github.com/DeanThompson/ginpprof v0.0.0-20201112072838-007b1e56b2e1/go.mod h1:kMi/fSDAgvjo9TYfYwYeQ2vkyj+VTR/tB6u/Tjh39t0=
 github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
 github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
 github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=

+ 5 - 8
websocket.go

@@ -6,6 +6,7 @@ import (
 	"net/http"
 	"time"
 
+	"github.com/DeanThompson/ginpprof"
 	"github.com/gin-gonic/gin"
 	"github.com/google/uuid"
 	"github.com/gorilla/websocket"
@@ -15,6 +16,8 @@ import (
 	"sikey.com/websocket/server"
 	"sikey.com/websocket/utils/mysqlx"
 	"sikey.com/websocket/utils/zlog"
+
+	_ "net/http/pprof"
 )
 
 var configFile = flag.String("f", "./etc/websocket.toml", "the config file")
@@ -32,14 +35,7 @@ func main() {
 
 func newApp() *gin.Engine {
 	app := gin.Default()
-
-	// 创建 Websocket 横向拓展应用
-	// exc := stackexchange.NewStackExchange(
-	// 	config.Kafka.Brokers,
-	// 	config.Kafka.Topic,
-	// 	config.Kafka.Partition,
-	// 	config.Kafka.MaxBytes,
-	// )
+	ginpprof.Wrap(app)
 
 	srv := &server.Server{
 		Upgrader: websocket.Upgrader{
@@ -66,5 +62,6 @@ func newApp() *gin.Engine {
 		Repositories: repositories.NewRepositories(mysqlx.ConnectMysql()),
 	}
 	app.GET("/websocket/endpoint", func(ctx *gin.Context) { server.WebsocketHandler(ctx, srv) })
+
 	return app
 }