|
@@ -6,6 +6,7 @@ import (
|
|
"net/http"
|
|
"net/http"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
+ "github.com/DeanThompson/ginpprof"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/google/uuid"
|
|
"github.com/google/uuid"
|
|
"github.com/gorilla/websocket"
|
|
"github.com/gorilla/websocket"
|
|
@@ -15,6 +16,8 @@ import (
|
|
"sikey.com/websocket/server"
|
|
"sikey.com/websocket/server"
|
|
"sikey.com/websocket/utils/mysqlx"
|
|
"sikey.com/websocket/utils/mysqlx"
|
|
"sikey.com/websocket/utils/zlog"
|
|
"sikey.com/websocket/utils/zlog"
|
|
|
|
+
|
|
|
|
+ _ "net/http/pprof"
|
|
)
|
|
)
|
|
|
|
|
|
var configFile = flag.String("f", "./etc/websocket.toml", "the config file")
|
|
var configFile = flag.String("f", "./etc/websocket.toml", "the config file")
|
|
@@ -32,14 +35,7 @@ func main() {
|
|
|
|
|
|
func newApp() *gin.Engine {
|
|
func newApp() *gin.Engine {
|
|
app := gin.Default()
|
|
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{
|
|
srv := &server.Server{
|
|
Upgrader: websocket.Upgrader{
|
|
Upgrader: websocket.Upgrader{
|
|
@@ -66,5 +62,6 @@ func newApp() *gin.Engine {
|
|
Repositories: repositories.NewRepositories(mysqlx.ConnectMysql()),
|
|
Repositories: repositories.NewRepositories(mysqlx.ConnectMysql()),
|
|
}
|
|
}
|
|
app.GET("/websocket/endpoint", func(ctx *gin.Context) { server.WebsocketHandler(ctx, srv) })
|
|
app.GET("/websocket/endpoint", func(ctx *gin.Context) { server.WebsocketHandler(ctx, srv) })
|
|
|
|
+
|
|
return app
|
|
return app
|
|
}
|
|
}
|