fix load bug

This commit is contained in:
Max 2022-02-09 21:46:25 +08:00
parent d763ad1ff4
commit 657d68d477
7 changed files with 27 additions and 4 deletions

View file

@ -143,7 +143,7 @@ xiang: bindata
.PHONY: release .PHONY: release
release: clean release: clean
mkdir -p dist/release mkdir -p dist/release
git clone git@github.com:YaoApp/xiang.git dist/release git clone git@github.com:YaoApp/yao.git dist/release
git clone git@github.com:YaoApp/kun.git dist/kun git clone git@github.com:YaoApp/kun.git dist/kun
git clone git@github.com:YaoApp/xun.git dist/xun git clone git@github.com:YaoApp/xun.git dist/xun
git clone git@github.com:YaoApp/gou.git dist/gou git clone git@github.com:YaoApp/gou.git dist/gou
@ -187,7 +187,7 @@ hi:
.PHONY: arm .PHONY: arm
arm: clean arm: clean
mkdir -p dist/release mkdir -p dist/release
git clone git@github.com:YaoApp/xiang.git dist/release git clone git@github.com:YaoApp/yao.git dist/release
git clone git@github.com:YaoApp/kun.git dist/kun git clone git@github.com:YaoApp/kun.git dist/kun
git clone git@github.com:YaoApp/xun.git dist/xun git clone git@github.com:YaoApp/xun.git dist/xun
git clone git@github.com:YaoApp/gou.git dist/gou git clone git@github.com:YaoApp/gou.git dist/gou
@ -219,7 +219,7 @@ arm: clean
.PHONY: linux .PHONY: linux
linux: clean linux: clean
mkdir -p dist/release mkdir -p dist/release
git clone git@github.com:YaoApp/xiang.git dist/release git clone git@github.com:YaoApp/yao.git dist/release
git clone git@github.com:YaoApp/kun.git dist/kun git clone git@github.com:YaoApp/kun.git dist/kun
git clone git@github.com:YaoApp/xun.git dist/xun git clone git@github.com:YaoApp/xun.git dist/xun
git clone git@github.com:YaoApp/gou.git dist/gou git clone git@github.com:YaoApp/gou.git dist/gou

View file

@ -22,6 +22,7 @@ var initCmd = &cobra.Command{
makeAppJSON() makeAppJSON()
makeEnv() makeEnv()
defaultApps() defaultApps()
fmt.Println(color.GreenString(L("✨DONE✨")))
}, },
} }

View file

@ -7,6 +7,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/yaoapp/gou" "github.com/yaoapp/gou"
"github.com/yaoapp/kun/exception"
"github.com/yaoapp/yao/config" "github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/engine" "github.com/yaoapp/yao/engine"
) )
@ -17,6 +18,13 @@ var migrateCmd = &cobra.Command{
Short: L("Update database schema"), Short: L("Update database schema"),
Long: L("Update database schema"), Long: L("Update database schema"),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
defer func() {
err := exception.Catch(recover())
if err != nil {
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
}
}()
Boot() Boot()
// 加载数据模型 // 加载数据模型
err := engine.Load(config.Conf) err := engine.Load(config.Conf)
@ -38,6 +46,8 @@ var migrateCmd = &cobra.Command{
fmt.Println(color.GreenString(L("Update schema model: %s (%s) "), mod.Name, mod.MetaData.Table.Name)) fmt.Println(color.GreenString(L("Update schema model: %s (%s) "), mod.Name, mod.MetaData.Table.Name))
mod.Migrate(true) mod.Migrate(true)
} }
fmt.Println(color.GreenString(L("✨DONE✨")))
}, },
} }

View file

@ -41,6 +41,7 @@ var langs = map[string]string{
"Update schema model: %s (%s) ": "更新表结构 model: %s (%s)", "Update schema model: %s (%s) ": "更新表结构 model: %s (%s)",
"Model name": "模型名称", "Model name": "模型名称",
"Initialize project": "项目初始化", "Initialize project": "项目初始化",
"✨DONE✨": "✨完成✨",
} }
// L 多语言切换 // L 多语言切换

View file

@ -8,6 +8,7 @@ import (
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/yaoapp/gou" "github.com/yaoapp/gou"
"github.com/yaoapp/kun/exception"
"github.com/yaoapp/kun/utils" "github.com/yaoapp/kun/utils"
"github.com/yaoapp/yao/config" "github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/engine" "github.com/yaoapp/yao/engine"
@ -20,6 +21,13 @@ var runCmd = &cobra.Command{
Long: L("Execute process"), Long: L("Execute process"),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
defer gou.KillPlugins() defer gou.KillPlugins()
defer func() {
err := exception.Catch(recover())
if err != nil {
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
}
}()
Boot() Boot()
cfg := config.Conf cfg := config.Conf
cfg.Session.IsCLI = true cfg.Session.IsCLI = true
@ -66,5 +74,7 @@ var runCmd = &cobra.Command{
fmt.Println(color.WhiteString(L("%s Response"), name)) fmt.Println(color.WhiteString(L("%s Response"), name))
fmt.Println(color.WhiteString("--------------------------------------")) fmt.Println(color.WhiteString("--------------------------------------"))
utils.Dump(res) utils.Dump(res)
fmt.Println(color.WhiteString("--------------------------------------"))
fmt.Println(color.GreenString(L("✨DONE✨")))
}, },
} }

View file

@ -97,6 +97,7 @@ var startCmd = &cobra.Command{
} }
} }
fmt.Println(color.GreenString(L("✨DONE✨")))
service.Start() service.Start()
}, },
} }

View file

@ -114,7 +114,7 @@ func LoadEngine(from ...string) {
if len(from) > 0 { if len(from) > 0 {
scripts = share.GetFilesFS(from[0], ".json") scripts = share.GetFilesFS(from[0], ".json")
} else { } else {
scripts = share.GetFilesBin("/xiang", ".json") scripts = share.GetFilesBin("xiang", ".json")
} }
if scripts == nil { if scripts == nil {