diff --git a/bin/boot.sh b/bin/boot.sh index ae8237b8..10c878a0 100755 --- a/bin/boot.sh +++ b/bin/boot.sh @@ -55,7 +55,7 @@ main() { trap HUP hup log "\nstarting..." while true; do - date && ${ctx_bin} "$@" && break + date && ${ctx_bin} "$@" 2>var/log/boot.log && break log "\n\nrestarting..." && sleep 1 done } diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index 720b929a..dfecabd1 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -203,12 +203,12 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", m.Append("NumCPU", runtime.NumCPU()) m.Append("NumGo", runtime.NumGoroutine()) m.Append("NumGC", mem.NumGC) - m.Append("other", kit.FmtSize(mem.OtherSys)) - m.Append("stack", kit.FmtSize(mem.StackSys)) - m.Append("heapsys", kit.FmtSize(mem.HeapSys)) - m.Append("heapidle", kit.FmtSize(mem.HeapIdle)) - m.Append("heapinuse", kit.FmtSize(mem.HeapInuse)) - m.Append("heapalloc", kit.FmtSize(mem.HeapAlloc)) + m.Append("other", kit.FmtSize(int64(mem.OtherSys))) + m.Append("stack", kit.FmtSize(int64(mem.StackSys))) + m.Append("heapsys", kit.FmtSize(int64(mem.HeapSys))) + m.Append("heapidle", kit.FmtSize(int64(mem.HeapIdle))) + m.Append("heapinuse", kit.FmtSize(int64(mem.HeapInuse))) + m.Append("heapalloc", kit.FmtSize(int64(mem.HeapAlloc))) m.Append("objects", mem.HeapObjects) m.Append("lookups", mem.Lookups) m.Table() @@ -248,6 +248,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", "cmd_temp": -1, "cmd_parse": 2, "cmd_error": 0, + "cmd_select": -1, "app_log": 1, }, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { // 管道参数 @@ -443,6 +444,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", } m.Echo(out.String()) } + if m.Has("cmd_select") { + m.Cmd("select", m.Meta["cmd_select"]) + } }) // 命令超时 @@ -962,7 +966,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", // 加载模块 if p, e := plugin.Open(path.Join(m.Conf("publish", "path"), arg[0], "index.so")); e == nil { if s, e := p.Lookup("Index"); m.Assert(e) { - m.Spawn(c.Register(*(s.(**ctx.Context)), nil, arg[0])).Cmd("_init", arg[1:]) + m.Spawn(c.Register(*(s.(**ctx.Context)), nil, arg[0]).Begin(m, arg[1:]...)).Cmd("_init", arg[1:]) } } @@ -974,7 +978,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", } // 查找脚本 - p := msg.Cmdx("nfs.path", path.Join(msg.Conf("project", "plugin.path"), arg[0], "index.shy")) + p := m.Cmdx("nfs.path", path.Join(msg.Conf("project", "plugin.path"), arg[0], "index.shy")) if p == "" { p = m.Cmdx("nfs.hash", m.Cmdx("web.get", "dev", fmt.Sprintf("publish/%s", arg[0]), "GOARCH", m.Conf("runtime", "host.GOARCH"), diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index f6ea1ac2..8111cea8 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -4,5 +4,5 @@ var version = struct { host string self int }{ - "2019-08-25 17:36:48", "mac", 429, + "2019-08-27 21:20:24", "centos", 428, } diff --git a/src/contexts/ctx/ctx.go b/src/contexts/ctx/ctx.go index 86ac8c27..90a468ae 100644 --- a/src/contexts/ctx/ctx.go +++ b/src/contexts/ctx/ctx.go @@ -26,7 +26,7 @@ func (ctx *CTX) Begin(m *Message, arg ...string) Server { m.Option("log.disable", true) m.Option("ctx.chain", "aaa", "ssh", "cli", "nfs") - m.Option("table.limit", 10) + m.Option("table.limit", 30) m.Option("table.offset", 0) m.Optionv("ctx.form", map[string]int{ "table.limit": 1, "table.offset": 1, @@ -89,7 +89,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{}, }, Help: "时间参数"}, "table": &Config{Name: "table", Value: map[string]interface{}{ "space": " ", "compact": "false", "col_sep": " ", "row_sep": "\n", - "offset": 0, "limit": 10, + "offset": 0, "limit": 30, }, Help: "制表"}, "call_timeout": &Config{Name: "call_timeout", Value: "60s", Help: "回调超时"}, }, @@ -839,7 +839,6 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{}, msg.Push(k, kit.Select("", arg, i)) } } - msg.Log("fuck", "waht %v", msg.Meta) return }}, "option": &Command{Name: "option", Help: "查看或添加选项", Hand: func(m *Message, c *Context, key string, arg ...string) (e error) { diff --git a/src/contexts/ctx/misc.go b/src/contexts/ctx/misc.go index fc97d9c7..90e4445a 100644 --- a/src/contexts/ctx/misc.go +++ b/src/contexts/ctx/misc.go @@ -55,7 +55,7 @@ func (m *Message) Show(str string, args ...interface{}) *Message { res := fmt.Sprintf(str, args...) if m.Option("bio.modal") == "action" { - fmt.Printf(res) + fmt.Fprintf(os.Stderr, res) } else if kit.STDIO != nil { kit.STDIO.Show(res) } else { diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index cc41ded3..1c08138d 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -574,6 +574,12 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", return } + p := path.Join("src/plugin", m.Option("plugin"), arg[0]) + if _, e := os.Stat(p); e == nil { + m.Echo(p) + return e + } + m.Confm("pwd", func(index int, value string) bool { p := path.Join(value, arg[0]) if _, e := os.Stat(p); e == nil { @@ -609,7 +615,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", "dir": &ctx.Command{Name: "dir [path [fields...]]", Help: []string{ "查看目录, path: 路径, fields...: 查询字段, time|type|full|path|name|tree|size|line|hash|hashs", "dir_deep: 递归查询", "dir_type both|file|dir|all: 文件类型", "dir_reg reg: 正则表达式", "dir_sort field order: 排序"}, - Form: map[string]int{"dir_deep": 0, "dir_type": 1, "dir_reg": 1, "dir_sort": 2, "dir_sed": -1}, + Form: map[string]int{"dir_deep": 0, "dir_type": 1, "dir_reg": 1, "dir_sort": 2, "dir_sed": -1, "dir_select": -1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { if len(arg) == 0 { arg = append(arg, "") @@ -679,7 +685,11 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", m.Echo(v).Echo(" ") } } else if !skip { - m.Table() + if m.Has("dir_select") { + m.Cmd("select", m.Meta["dir_select"]) + } else { + m.Table() + } } return }}, diff --git a/src/contexts/ssh/ssh.go b/src/contexts/ssh/ssh.go index bf3ac0aa..f109b045 100644 --- a/src/contexts/ssh/ssh.go +++ b/src/contexts/ssh/ssh.go @@ -275,7 +275,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", case "trust": if len(arg) > 1 { - m.Conf("trust", arg[1], kit.Right(arg[2])) + m.Conf("trust", arg[1], kit.Right(kit.Select("true", arg, 2))) } if len(arg) > 1 { m.Cmdy("ctx.config", "trust", arg[1]) @@ -352,6 +352,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", switch arg[0] { case "run": + m.Option("plugin", arg[1]) tool := m.Confm("componet", []string{arg[1], arg[2]}) if m.Option("userrole") != "root" { switch kit.Format(tool["componet_type"]) { @@ -376,10 +377,15 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", arg = arg[4:] args := []string{} for _, v := range kit.Trans(tool["componet_args"]) { - if v == "$$" { + if strings.HasPrefix(v, "__") { if len(arg) > 0 { - args = append(args, arg[0]) - arg = arg[1:] + args, arg = append(args, arg...), nil + } else { + args = append(args, "") + } + } else if strings.HasPrefix(v, "_") { + if len(arg) > 0 { + args, arg = append(args, arg[0]), arg[1:] } else { args = append(args, "") } diff --git a/src/contexts/yac/yac.go b/src/contexts/yac/yac.go index e8c9037b..f02f581d 100644 --- a/src/contexts/yac/yac.go +++ b/src/contexts/yac/yac.go @@ -1081,7 +1081,7 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心", m.Log("stack", "push %v", p.String("\\")) if len(arg) > 2 { - m.Cmd("kit", "kit", arg[5], arg[1:5], arg[1], arg[6:]) + m.Cmd("kit", "kit", arg[1:6], arg[1], arg[6:]) } self := &ctx.Command{Name: strings.Join(arg[1:], " "), Help: []string{"pwd", "ls"}} self.Hand = func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { @@ -1147,11 +1147,11 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心", } m.Confv("_index", []interface{}{-2}, map[string]interface{}{ - "componet_type": kit.Select("public", arg, 1), - "componet_name": kit.Select("", arg, 2), - "componet_help": kit.Select("", arg, 3), - "componet_view": kit.Select("componet", arg, 4), - "componet_init": kit.Select("", arg, 5), + "componet_type": kit.Select("public", arg, 5), + "componet_name": kit.Select("", arg, 1), + "componet_help": kit.Select("", arg, 2), + "componet_view": kit.Select("componet", arg, 3), + "componet_init": kit.Select("", arg, 4), "componet_ctx": m.Cap("module"), "componet_cmd": kit.Select("", arg, 6), diff --git a/src/toolkit/misc.go b/src/toolkit/misc.go index e2bfc125..58db9b93 100644 --- a/src/toolkit/misc.go +++ b/src/toolkit/misc.go @@ -58,7 +58,7 @@ func Split(str string, n int) []string { } return res } -func FmtSize(size uint64) string { +func FmtSize(size int64) string { if size > 1<<30 { return fmt.Sprintf("%d.%dG", size>>30, (size>>20)%1024*100/1024) } @@ -73,15 +73,19 @@ func FmtSize(size uint64) string { return fmt.Sprintf("%dB", size) } -func FmtTime(time int64) string { +func FmtTime(t int64) string { + sign, time := "", t + if time < 0 { + sign, time = "-", -t + } if time > 1000000000 { - return fmt.Sprintf("%d.%ds", time/1000000000, (time/1000000)%1000*100/1000) + return fmt.Sprintf("%s%d.%ds", sign, time/1000000000, (time/1000000)%1000*100/1000) } if time > 1000000 { - return fmt.Sprintf("%d.%dms", time/1000000, (time/1000)%1000*100/1000) + return fmt.Sprintf("%s%d.%dms", sign, time/1000000, (time/1000)%1000*100/1000) } if time > 1000 { - return fmt.Sprintf("%d.%dus", time/1000, (time/1000)%1000*100/1000) + return fmt.Sprintf("%s%d.%dus", sign, time/1000, (time/1000)%1000*100/1000) } - return fmt.Sprintf("%dns", time) + return fmt.Sprintf("%s%dns", sign, time) } diff --git a/usr/librarys/example.css b/usr/librarys/example.css index 23fef993..ae774455 100644 --- a/usr/librarys/example.css +++ b/usr/librarys/example.css @@ -48,6 +48,9 @@ fieldset>form.option div.cmd input.args { background-color: black; width:160px; } +fieldset>form.option div.tiny input.args { + width:20px; +} fieldset>form.option div.long input.args { width:240px; }