wireguard-dashboard/main.go
coward 1950150f42
All checks were successful
continuous-integration/drone/tag Build is passing
🎨新增pprof监控
2024-06-17 15:30:47 +08:00

50 lines
1.0 KiB
Go

package main
import (
"fmt"
"gitee.ltd/lxh/logger/log"
"github.com/gin-contrib/pprof"
"math/rand"
"net/http"
"time"
"wireguard-dashboard/config"
"wireguard-dashboard/cron_task"
"wireguard-dashboard/initialize"
"wireguard-dashboard/queues"
"wireguard-dashboard/route"
"wireguard-dashboard/script"
)
func init() {
initialize.Init() // 初始化
if err := script.NewScript().Do(); err != nil {
log.Errorf("执行脚本失败: %v", err.Error())
}
go queues.StartConsumer() // 启动队列
go cron_task.StartCronTask() // 启动定时任务
}
func main() {
rand.New(rand.NewSource(time.Now().Local().UnixNano()))
route.IncludeRouters(
route.CaptchaApi,
route.UserApi,
route.ServerApi,
route.ClientApi,
route.SettingApi,
route.DashboardApi,
)
handler := route.InitRouter()
pprof.Register(handler)
httpServe := http.Server{
Addr: fmt.Sprintf(":%d", config.Config.Http.Port),
Handler: handler,
}
if err := httpServe.ListenAndServe(); err != nil {
log.Panicf("启动http服务端失败: %v", err.Error())
}
}