管理端全部功能跑通
This commit is contained in:
43
EdgeHttpDNS/cmd/edge-httpdns/main.go
Normal file
43
EdgeHttpDNS/cmd/edge-httpdns/main.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/TeaOSLab/EdgeHttpDNS/internal/apps"
|
||||
"github.com/TeaOSLab/EdgeHttpDNS/internal/configs"
|
||||
teaconst "github.com/TeaOSLab/EdgeHttpDNS/internal/const"
|
||||
"github.com/TeaOSLab/EdgeHttpDNS/internal/nodes"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := apps.NewAppCmd().
|
||||
Version(teaconst.Version).
|
||||
Product(teaconst.ProductName).
|
||||
Usage(teaconst.ProcessName + " [-v|start|stop|restart|status|service|daemon]")
|
||||
|
||||
app.On("start:before", func() {
|
||||
_, err := configs.LoadAPIConfig()
|
||||
if err != nil {
|
||||
fmt.Println("[ERROR]start failed: load config from '" + configs.ConfigFileName + "' failed: " + err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
app.On("daemon", func() {
|
||||
nodes.NewHTTPDNSNode().Daemon()
|
||||
})
|
||||
|
||||
app.On("service", func() {
|
||||
err := nodes.NewHTTPDNSNode().InstallSystemService()
|
||||
if err != nil {
|
||||
fmt.Println("[ERROR]install failed: " + err.Error())
|
||||
return
|
||||
}
|
||||
fmt.Println("done")
|
||||
})
|
||||
|
||||
app.Run(func() {
|
||||
nodes.NewHTTPDNSNode().Run()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user