wireguard-dashboard/main.go

46 lines
969 B
Go
Raw Normal View History

2024-03-05 16:59:37 +08:00
package main
import (
"fmt"
2024-03-07 15:11:29 +08:00
"gitee.ltd/lxh/logger/log"
2024-06-06 17:02:45 +08:00
"math/rand"
2024-03-05 16:59:37 +08:00
"net/http"
2024-06-06 17:02:45 +08:00
"time"
2024-03-05 16:59:37 +08:00
"wireguard-dashboard/config"
2024-06-17 10:20:46 +08:00
"wireguard-dashboard/cron_task"
2024-03-05 16:59:37 +08:00
"wireguard-dashboard/initialize"
"wireguard-dashboard/route"
"wireguard-dashboard/script"
2024-03-05 16:59:37 +08:00
)
func init() {
initialize.Init() // 初始化
if err := script.NewScript().Do(); err != nil {
2024-03-07 15:11:29 +08:00
log.Errorf("执行脚本失败: %v", err.Error())
}
2024-06-17 10:20:46 +08:00
//go queues.StartConsumer() // 启动队列
go cron_task.StartCronTask() // 启动定时任务
2024-03-05 16:59:37 +08:00
}
func main() {
2024-06-06 17:02:45 +08:00
rand.New(rand.NewSource(time.Now().Local().UnixNano()))
2024-03-06 17:13:29 +08:00
route.IncludeRouters(
2024-03-07 17:07:41 +08:00
route.CaptchaApi,
2024-03-06 17:13:29 +08:00
route.UserApi,
2024-03-07 17:07:41 +08:00
route.ServerApi,
2024-03-11 14:53:28 +08:00
route.ClientApi,
2024-03-14 15:23:16 +08:00
route.SettingApi,
2024-06-03 17:09:45 +08:00
route.DashboardApi,
2024-03-06 17:13:29 +08:00
)
2024-03-05 16:59:37 +08:00
handler := route.InitRouter()
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())
}
}