From e232ffc59e02f52e6dd591da6a9519cefdec161d Mon Sep 17 00:00:00 2001 From: harveyshao Date: Mon, 8 Aug 2022 14:49:06 +0800 Subject: [PATCH] opt some --- base/cli/forever.go | 1 + base/cli/system.go | 3 +++ base/gdb/signal.go | 2 +- base/log/log.go | 2 +- core/chat/sso.go | 7 ++----- core/code/publish.go | 4 ++-- logs.go | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/base/cli/forever.go b/base/cli/forever.go index 813976fb..4e56a936 100644 --- a/base/cli/forever.go +++ b/base/cli/forever.go @@ -55,6 +55,7 @@ func init() { for { logs.Println("run %s", kit.Join(arg, ice.SP)) if m.Sleep300ms(); IsSuccess(m.Cmd(SYSTEM, arg)) { + logs.Println() logs.Println(ice.EXIT) // 正常退出 break } else { diff --git a/base/cli/system.go b/base/cli/system.go index 94fa491c..11160678 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -146,6 +146,9 @@ func init() { m.Cmdy(nfs.CAT, ice.ETC_PATH) }}, }, Hand: func(m *ice.Message, arg ...string) { + if len(arg) == 0 { + return + } if len(arg) == 1 { arg = kit.Split(arg[0]) } diff --git a/base/gdb/signal.go b/base/gdb/signal.go index 3ecd836f..fd42eca5 100644 --- a/base/gdb/signal.go +++ b/base/gdb/signal.go @@ -58,7 +58,7 @@ func init() { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _signal_listen(m, 2, mdb.NAME, "重启", ice.CMD, "exit 1") _signal_listen(m, 3, mdb.NAME, "退出", ice.CMD, "exit 0") - if f, p, e := logs.CreateFile(ice.Info.PidPath); !m.Warn(e) { + if f, p, e := logs.CreateFile(ice.Info.PidPath); e == nil { defer f.Close() fmt.Fprint(f, os.Getpid()) m.Logs(mdb.CREATE, PID, p) diff --git a/base/log/log.go b/base/log/log.go index ce77be52..572888e6 100644 --- a/base/log/log.go +++ b/base/log/log.go @@ -134,7 +134,7 @@ var Index = &ice.Context{Name: "log", Help: "日志模块", Configs: ice.Configs m.Conf(SHOW, kit.Keys(k, FILE), key) }) // 日志文件 - if f, p, e := logs.CreateFile(kit.Format(value[nfs.PATH])); m.Assert(e) { + if f, p, e := logs.CreateFile(kit.Format(value[nfs.PATH])); e == nil { m.Cap(ice.CTX_STREAM, path.Base(p)) value[FILE] = bufio.NewWriter(f) m.Logs(mdb.CREATE, nfs.FILE, p) diff --git a/core/chat/sso.go b/core/chat/sso.go index e082344c..93f26485 100644 --- a/core/chat/sso.go +++ b/core/chat/sso.go @@ -23,11 +23,8 @@ func init() { if m.Warn(m.Option(cli.BACK) == "") { return } - sessid := m.Cmdx(web.SPACE, m.Option(web.SPACE), aaa.SESS, mdb.CREATE, - aaa.USERNAME, m.Option(ice.MSG_USERNAME), - aaa.USERROLE, m.Option(ice.MSG_USERROLE), - aaa.USERNICK, m.Option(ice.MSG_USERNICK), - ) + args := []string{aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE), aaa.USERNICK, m.Option(ice.MSG_USERNICK)} + sessid := aaa.UserRoot(m).Cmdx(web.SPACE, m.Option(web.SPACE), aaa.SESS, mdb.CREATE, args) m.RenderRedirect(kit.MergeURL(m.Option(cli.BACK), ice.MSG_SESSID, sessid)) }}, }) diff --git a/core/code/publish.go b/core/code/publish.go index 5fa45df5..773fd7c8 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -159,8 +159,8 @@ func init() { var _contexts = kit.Dict( ice.MISC, `# 下载命令 -export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp app -export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app +export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp app username {{.Option "user.name"}} +export ctx_dev={{.Option "httphost"}} ctx_pod={{.Option "user.pod"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}} `, ice.CORE, `# 克隆源码 git clone {{.Option "remote"}}; cd {{.Option "pathname"}} && source etc/miss.sh port 9020 diff --git a/logs.go b/logs.go index 27dcd90c..3f7bb008 100644 --- a/logs.go +++ b/logs.go @@ -195,7 +195,7 @@ func (m *Message) FormatStack(s, n int) string { name := kit.Slice(kit.Split(frame.Function, PS, PS), -1)[0] switch ls := kit.Split(name, PT, PT); kit.Select("", ls, 0) { - case "reflect", "runtime", "http", "task", "icebergs": + // case "reflect", "runtime", "http", "task", "icebergs": default: list = append(list, kit.Format("%s:%d\t%s", file, frame.Line, name)) }