package main import ( "fmt" "gitee.ltd/lxh/logger/log" "github.com/gin-contrib/pprof" "github.com/spf13/cast" "math/rand" "net/http" "os" "time" "wireguard-ui/config" "wireguard-ui/cron" "wireguard-ui/http/router" "wireguard-ui/initialize" "wireguard-ui/script" ) func init() { initialize.Init() if err := script.New().Do(); err != nil { log.Errorf("执行脚本失败: %v", err.Error()) } // 启动定时任务 go cron.Task() } func main() { rand.New(rand.NewSource(time.Now().Local().UnixNano())) router.Rooters() handler := router.InitRouter() if cast.ToBool(os.Getenv("ENABLED_PPROF")) { pprof.Register(handler, "/monitoring") } 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()) } }