添加基础性能测试分析代码

This commit is contained in:
2025-03-05 18:12:26 +08:00
parent 6e2309df2d
commit 736dbff17d
11 changed files with 106 additions and 141 deletions

View File

@@ -107,7 +107,7 @@ func (s *Service) Run() {
// 清理资源
s.userConnMap.Range(func(key, value any) bool {
conn := value.(core.Conn)
conn := value.(*core.Conn)
utils.Close(conn)
return true
})

View File

@@ -3,6 +3,7 @@ package server
import (
"context"
"log/slog"
"net/http"
"os"
"os/signal"
"proxy-server/pkg/utils"
@@ -17,6 +18,8 @@ import (
"github.com/joho/godotenv"
)
import _ "net/http/pprof"
type Context struct {
context.Context
log *slog.Logger
@@ -34,6 +37,14 @@ func Start() {
env.Init()
orm.Init()
// 性能监控
go func() {
err := http.ListenAndServe(":6060", nil)
if err != nil {
slog.Error("性能监控服务发生错误", "err", err)
}
}()
// 退出信号
osQuit := make(chan os.Signal)
signal.Notify(osQuit, os.Interrupt, syscall.SIGTERM)