wireguard-dashboard/main.go

57 lines
1.0 KiB
Go
Raw Normal View History

2024-07-05 14:41:35 +08:00
package main
import (
"gitee.ltd/lxh/logger/log"
2024-12-13 15:07:57 +08:00
"github.com/urfave/cli/v2"
2024-07-05 14:41:35 +08:00
"math/rand"
"os"
2024-12-13 15:07:57 +08:00
"sort"
2024-07-05 14:41:35 +08:00
"time"
2024-12-13 15:07:57 +08:00
tui "wireguard-ui/cli"
2024-12-27 11:50:52 +08:00
"wireguard-ui/cron"
2024-12-13 15:07:57 +08:00
"wireguard-ui/http"
2024-07-05 14:41:35 +08:00
"wireguard-ui/initialize"
"wireguard-ui/script"
)
func init() {
initialize.Init()
if err := script.New().Do(); err != nil {
log.Errorf("执行脚本失败: %v", err.Error())
}
2024-12-27 11:50:52 +08:00
cron.Task()
2024-07-05 14:41:35 +08:00
}
func main() {
rand.New(rand.NewSource(time.Now().Local().UnixNano()))
2024-12-13 15:07:57 +08:00
app := &cli.App{
2024-12-13 15:09:24 +08:00
Name: "wireguard-ui",
Usage: "wireguard-manager-ui",
2024-07-05 14:41:35 +08:00
}
2024-12-13 15:07:57 +08:00
app.Commands = []*cli.Command{
{
Name: "http:serve",
Aliases: []string{"app:serve"},
Usage: "",
Action: func(ctx *cli.Context) error {
return http.Kernel()
},
},
{
Name: "cmd:serve",
Aliases: []string{"command:serve"},
Usage: "use command exec",
Action: func(ctx *cli.Context) error {
return tui.Kernel()
},
},
2024-07-05 14:41:35 +08:00
}
2024-12-13 15:07:57 +08:00
sort.Sort(cli.CommandsByName(app.Commands))
if err := app.Run(os.Args); err != nil {
log.Fatalf("服务启动失败: %v", err.Error())
2024-07-05 14:41:35 +08:00
}
}