wireguard-dashboard/main.go
coward f09d0d2994
Some checks reported errors
continuous-integration/drone/tag Build was killed
🎨调整定时任务执行时间,以及启动时间
2024-12-05 11:49:29 +08:00

48 lines
887 B
Go

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())
}
}
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")
}
// 启动定时任务
cron.Task()
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())
}
}