diff --git a/cmd/run.go b/cmd/run.go index 922077d6..07333db7 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -33,13 +33,17 @@ var runCmd = &cobra.Command{ Boot() cfg := config.Conf cfg.Session.IsCLI = true - engine.Load(cfg) if len(args) < 1 { fmt.Println(color.RedString(L("Not enough arguments"))) fmt.Println(color.WhiteString(share.BUILDNAME + " help")) return } + err := engine.Load(cfg) + if err != nil { + fmt.Println(color.RedString(L("Engine: %s"), err.Error())) + } + name := args[0] fmt.Println(color.GreenString(L("Run: %s"), name)) pargs := []interface{}{} @@ -48,7 +52,7 @@ var runCmd = &cobra.Command{ continue } - // 解析参数 + // Parse the arguments if strings.HasPrefix(arg, "::") { arg := strings.TrimPrefix(arg, "::") var v interface{} @@ -59,10 +63,12 @@ var runCmd = &cobra.Command{ } pargs = append(pargs, v) fmt.Println(color.WhiteString("args[%d]: %s", i-1, arg)) + } else if strings.HasPrefix(arg, "\\::") { arg := "::" + strings.TrimPrefix(arg, "\\::") pargs = append(pargs, arg) fmt.Println(color.WhiteString("args[%d]: %s", i-1, arg)) + } else { pargs = append(pargs, arg) fmt.Println(color.WhiteString("args[%d]: %s", i-1, arg)) @@ -71,7 +77,11 @@ var runCmd = &cobra.Command{ } process := process.New(name, pargs...) - res := process.Run() + res, err := process.Exec() + if err != nil { + fmt.Println(color.RedString(L("Process: %s"), err.Error())) + } + fmt.Println(color.WhiteString("--------------------------------------")) fmt.Println(color.WhiteString(L("%s Response"), name)) fmt.Println(color.WhiteString("--------------------------------------")) diff --git a/cmd/start.go b/cmd/start.go index 0aecbed3..b2e8659d 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -13,6 +13,7 @@ import ( "github.com/yaoapp/gou/api" "github.com/yaoapp/gou/connector" "github.com/yaoapp/gou/fs" + "github.com/yaoapp/gou/plugin" "github.com/yaoapp/gou/schedule" "github.com/yaoapp/gou/server/http" "github.com/yaoapp/gou/store" @@ -35,6 +36,9 @@ var startCmd = &cobra.Command{ Long: L("Start Engine"), Run: func(cmd *cobra.Command, args []string) { + defer share.SessionStop() + defer plugin.KillAll() + // Setup if setup.Check() { go setup.Start()