Files
EdgeAdmin/cmd/edge-admin/main.go

50 lines
1.2 KiB
Go
Raw Normal View History

2020-07-22 09:59:40 +08:00
package main
import (
"github.com/TeaOSLab/EdgeAdmin/internal/apps"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web"
"github.com/iwind/TeaGo"
2020-07-22 22:19:39 +08:00
"github.com/iwind/TeaGo/Tea"
2020-07-22 09:59:40 +08:00
_ "github.com/iwind/TeaGo/bootstrap"
2020-10-13 20:05:29 +08:00
"github.com/iwind/TeaGo/logs"
2020-07-22 09:59:40 +08:00
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/sessions"
2020-10-13 20:05:29 +08:00
"os"
"os/exec"
2020-07-22 09:59:40 +08:00
)
func main() {
app := apps.NewAppCmd().
Version(teaconst.Version).
Product(teaconst.ProductName).
Usage(teaconst.ProcessName + " [-v|start|stop|restart]")
app.Run(func() {
// 启动管理界面
2020-07-22 22:19:39 +08:00
secret := rands.String(32)
// 测试环境下设置一个固定的key方便我们调试
if Tea.IsTesting() {
secret = "8f983f4d69b83aaa0d74b21a212f6967"
}
2020-10-13 20:05:29 +08:00
// 启动API节点
_, err := os.Stat(Tea.Root + "/edge-api/configs/api.yaml")
if err == nil {
logs.Println("start edge-api")
err = exec.Command(Tea.Root + "/edge-api/bin/edge-api").Start()
if err != nil {
logs.Println("[ERROR]start edge-api failed: " + err.Error())
}
}
2020-07-22 09:59:40 +08:00
server := TeaGo.NewServer(false).
AccessLog(false).
EndAll().
2020-07-22 22:19:39 +08:00
Session(sessions.NewFileSessionManager(86400, secret))
2020-07-22 09:59:40 +08:00
server.Start()
})
}