wireguard-dashboard/main.go
coward 36f0202c57
All checks were successful
continuous-integration/drone/tag Build is passing
🎨定时任务掉了
2024-12-27 11:50:52 +08:00

57 lines
1.0 KiB
Go

package main
import (
"gitee.ltd/lxh/logger/log"
"github.com/urfave/cli/v2"
"math/rand"
"os"
"sort"
"time"
tui "wireguard-ui/cli"
"wireguard-ui/cron"
"wireguard-ui/http"
"wireguard-ui/initialize"
"wireguard-ui/script"
)
func init() {
initialize.Init()
if err := script.New().Do(); err != nil {
log.Errorf("执行脚本失败: %v", err.Error())
}
cron.Task()
}
func main() {
rand.New(rand.NewSource(time.Now().Local().UnixNano()))
app := &cli.App{
Name: "wireguard-ui",
Usage: "wireguard-manager-ui",
}
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()
},
},
}
sort.Sort(cli.CommandsByName(app.Commands))
if err := app.Run(os.Args); err != nil {
log.Fatalf("服务启动失败: %v", err.Error())
}
}