mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	初步实现安装界面
This commit is contained in:
		@@ -1,18 +1,47 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/apps"
 | 
			
		||||
	teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/nodes"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/setup"
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAPI/internal/tasks"
 | 
			
		||||
	"github.com/iwind/TeaGo/Tea"
 | 
			
		||||
	_ "github.com/iwind/TeaGo/bootstrap"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
	"log"
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	if !Tea.IsTesting() {
 | 
			
		||||
		Tea.Env = "prod"
 | 
			
		||||
	}
 | 
			
		||||
	app := apps.NewAppCmd()
 | 
			
		||||
	app.Version(teaconst.Version)
 | 
			
		||||
	app.Product(teaconst.ProductName)
 | 
			
		||||
	app.Usage(teaconst.ProcessName + " [start|stop|restart]")
 | 
			
		||||
	app.Usage(teaconst.ProcessName + " [start|stop|restart|setup]")
 | 
			
		||||
	app.On("setup", func() {
 | 
			
		||||
		setupCmd := setup.NewSetupFromCmd()
 | 
			
		||||
		err := setupCmd.Run()
 | 
			
		||||
		result := maps.Map{}
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			result["isOk"] = false
 | 
			
		||||
			result["error"] = err.Error()
 | 
			
		||||
		} else {
 | 
			
		||||
			result["isOk"] = true
 | 
			
		||||
			result["adminNodeId"] = setupCmd.AdminNodeId
 | 
			
		||||
			result["adminNodeSecret"] = setupCmd.AdminNodeSecret
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		resultJSON, err := json.Marshal(result)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err.Error())
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		_, _ = os.Stdout.Write(resultJSON)
 | 
			
		||||
	})
 | 
			
		||||
	app.Run(func() {
 | 
			
		||||
		nodes.NewAPINode().Start()
 | 
			
		||||
	})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user