From 8d82f56bf92aae4699b135cb0f5e5e5f01f9cc60 Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 14 Feb 2022 13:04:38 +0800 Subject: [PATCH] opt some --- base/cli/forever.go | 2 ++ base/cli/system.go | 3 +++ base/web/dream.go | 3 ++- core/code/compile.go | 1 + core/code/install.go | 1 - core/code/vimer.go | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/base/cli/forever.go b/base/cli/forever.go index 9884d6cb..bfb3897e 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -26,6 +26,8 @@ func init() { } } println(kit.Format("%s run %s", kit.Now(), kit.Join(arg, ice.SP))) + m.Option(CMD_OUTPUT, os.Stdout) + m.Option(CMD_ERRPUT, os.Stderr) switch msg := m.Cmd(SYSTEM, arg); msg.Append(CODE) { case "0": println(kit.Format("%s exit", kit.Now())) diff --git a/base/cli/system.go b/base/cli/system.go index 018b5925..217c2dd2 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -109,6 +109,9 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) { func IsSuccess(m *ice.Message) bool { return m.Append(CODE) == "0" || m.Append(CODE) == "" } +func SystemFind(m *ice.Message, bin string, dir ...string) string { + return _system_find(m, bin, dir...) +} const ( CMD_DIR = "cmd_dir" diff --git a/base/web/dream.go b/base/web/dream.go index 8c50188b..6f6950f5 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -88,7 +88,8 @@ func _dream_show(m *ice.Message, name string) { m.Optionv(cli.CMD_OUTPUT, path.Join(p, m.Config(kit.Keys(cli.ENV, cli.CTX_LOG)))) // 启动任务 - m.Cmd(cli.DAEMON, kit.Path(os.Args[0]), SPACE, tcp.DIAL, ice.DEV, ice.OPS, mdb.NAME, name, m.OptionSimple(RIVER)) + bin := cli.SystemFind(m, "ice.bin", kit.Path(path.Join(p, ice.BIN)), "./bin") + m.Cmd(cli.DAEMON, kit.Select(kit.Path(os.Args[0]), bin), SPACE, tcp.DIAL, ice.DEV, ice.OPS, mdb.NAME, name, m.OptionSimple(RIVER)) defer m.Event(DREAM_CREATE, kit.SimpleKV("", m.Option(mdb.TYPE), name)...) m.Sleep3s() } diff --git a/core/code/compile.go b/core/code/compile.go index 40d57f18..bf2eb14a 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -36,6 +36,7 @@ func init() { if m.Cmdx(cli.SYSTEM, nfs.FIND, "go") == "" { m.Cmd(INSTALL, COMPILE) } + m.Cmd(cli.SYSTEM, "go", "get", "shylinux.com/x/ice") // 交叉编译 main, file := ice.SRC_MAIN_GO, "" diff --git a/core/code/install.go b/core/code/install.go index c5388147..cb302d84 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -184,7 +184,6 @@ func init() { switch { case strings.Contains(osid, cli.ALPINE): m.Cmd(cli.SYSTEM, "apk", "add", "git", "go") - m.Cmd(cli.SYSTEM, "go", "get", "shylinux.com/x/ice") case strings.Contains(osid, cli.CENTOS): m.Cmdy(INSTALL, web.DOWNLOAD, "https://golang.google.cn/dl/go1.15.5.linux-amd64.tar.gz", ice.USR_LOCAL) diff --git a/core/code/vimer.go b/core/code/vimer.go index c5353810..f0ca34e2 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -39,6 +39,7 @@ func init() { m.Cmd(nfs.COPY, ice.GO_MOD, path.Join(ice.SRC_DEBUG, ice.GO_MOD)) m.Cmd(nfs.COPY, ice.GO_SUM, path.Join(ice.SRC_DEBUG, ice.GO_SUM)) m.Cmdy(WEBPACK, mdb.REMOVE) + m.ToastSuccess() m.ProcessHold() }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Cmdy(INNER, arg) }},