44 lines
975 B
Go
44 lines
975 B
Go
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()
|
|
})
|
|
}
|