diff --git a/base/cli/runtime.go b/base/cli/runtime.go index a68abc21..674c57c5 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -67,6 +67,7 @@ func _runtime_init(m *ice.Message) { } }) }) + m.Conf(m.PrefixKey(), mdb.META, "") } func _runtime_hostinfo(m *ice.Message) { m.Push("time", ice.Info.Make.Time) diff --git a/base/web/dream.go b/base/web/dream.go index a82cbf41..936d6cdb 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -77,7 +77,7 @@ func _dream_list_icon(m *ice.Message) { return value }) } -func _dream_more_list(m *ice.Message) *ice.Message { +func _dream_list_more(m *ice.Message) *ice.Message { if m.IsCliUA() { return m } @@ -93,6 +93,7 @@ func _dream_more_list(m *ice.Message) *ice.Message { msg := gdb.Event(m.Spawn(value), DREAM_TABLES) defer m.PushButton(strings.Join(msg.Appendv(ctx.ACTION), "")) case MASTER: + value[mdb.ICON] = nfs.USR_ICONS_CONTEXTS if spide, ok := list[value[mdb.NAME]]; ok { value[mdb.ICON] = kit.Select(value[mdb.ICON], spide[mdb.ICON]) } @@ -424,21 +425,18 @@ func init() { if len(arg) == 0 { _dream_list(m) _dream_list_icon(m) - _dream_more_list(m) + _dream_list_more(m) stat := map[string]int{} m.Table(func(value ice.Maps) { stat[value[mdb.TYPE]]++; stat[value[mdb.STATUS]]++ }) kit.If(stat[cli.START] == stat[WORKER], func() { delete(stat, cli.START) }) m.Sort("type,status,name", []string{aaa.LOGIN, WORKER, SERVER, MASTER}, []string{cli.START, cli.STOP, cli.BEGIN}, ice.STR_R).StatusTimeCount(stat) - ctx.DisplayTableCard(m) - if ice.Info.NodeType == WORKER || !aaa.IsTechOrRoot(m) || m.IsCliUA() { + if ctx.DisplayTableCard(m); ice.Info.NodeType == WORKER || !aaa.IsTechOrRoot(m) || m.IsCliUA() { m.Action() - return - } - kit.If(cli.SystemFind(m, "go"), func() { + } else if cli.SystemFind(m, "go") == "" { + m.Action(html.FILTER, mdb.CREATE, STARTALL, STOPALL) + } else { m.Action(html.FILTER, mdb.CREATE, STARTALL, STOPALL, cli.BUILD, PUBLISH) - }, func() { - m.Action(mdb.CREATE, STARTALL, STOPALL) - }) + } } else if arg[0] == ctx.ACTION { gdb.Event(m, DREAM_ACTION, arg) } else { diff --git a/base/web/spide.go b/base/web/spide.go index 33de0b9b..d74a99ab 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -268,6 +268,7 @@ var agentIcons = map[string]string{ html.Chrome: "usr/icons/Chrome.png", html.Edg: "usr/icons/Edg.png", html.MicroMessenger: "usr/icons/wechat.png", + "Go-http-client": "usr/icons/go.png", } const SPIDE = "spide" @@ -283,10 +284,10 @@ func init() { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { conf := mdb.Confm(m, cli.RUNTIME, cli.CONF) dev := kit.Select("https://2021.shylinux.com", ice.Info.Make.Domain, conf[cli.CTX_DEV]) - m.Cmd("", mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com", conf[cli.CTX_SHY]), nfs.REPOS, nfs.USR_ICONS_CONTEXTS) + m.Cmd("", mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com", conf[cli.CTX_SHY]), nfs.REPOS) m.Cmd("", mdb.CREATE, ice.DEV, dev, nfs.REPOS) m.Cmd("", mdb.CREATE, ice.DEV_IP, kit.Select(dev, os.Getenv("ctx_dev_ip"))) - m.Cmd("", mdb.CREATE, ice.OPS, kit.Select("http://localhost:9020", conf[cli.CTX_OPS]), nfs.REPOS, nfs.USR_ICONS_VOLCANOS) + m.Cmd("", mdb.CREATE, ice.OPS, kit.Select("http://localhost:9020", conf[cli.CTX_OPS]), nfs.REPOS) m.Cmd("", mdb.CREATE, ice.DEMO, kit.Select("http://localhost:20000", conf[cli.CTX_DEMO]), "", nfs.USR_ICONS_VOLCANOS) m.Cmd("", mdb.CREATE, ice.MAIL, kit.Select("https://mail.shylinux.com", conf[cli.CTX_MAIL]), "", "usr/icons/Mail.png") if m.Cmd(tcp.HOST).Length() == 0 { @@ -336,7 +337,7 @@ func init() { } }}, mdb.CREATE: {Name: "create name* origin* type icons", Hand: func(m *ice.Message, arg ...string) { - _spide_create(m, m.Option(mdb.NAME), m.Option(ORIGIN), m.Option(mdb.TYPE), m.OptionDefault(mdb.ICONS, nfs.USR_ICONS_ICEBERGS)) + _spide_create(m, m.Option(mdb.NAME), m.Option(ORIGIN), m.Option(mdb.TYPE), m.OptionDefault(mdb.ICONS, nfs.USR_ICONS_CONTEXTS)) }}, COOKIE: {Name: "cookie key* value", Help: "状态量", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(CLIENT_NAME), kit.Keys(COOKIE, m.Option(mdb.KEY)), m.Option(mdb.VALUE)) diff --git a/core/chat/pod.go b/core/chat/pod.go index 71aa7ad3..f5af403e 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -19,7 +19,10 @@ func init() { Index.MergeCommands(ice.Commands{ POD: {Help: "空间", Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { if m.IsCliUA() { - if len(arg) == 0 || arg[0] == "" { + if len(arg) > 1 { + m.Option(ice.MSG_USERPOD, arg[0]) + m.Cmdy(web.SPACE, arg[0], arg[2], arg[3:]) + } else if len(arg) == 0 || arg[0] == "" { m.Option(ice.MSG_USERROLE, aaa.TECH) m.Cmd(web.SPACE, func(value ice.Maps) { msg := m.Cmd(nfs.DIR, path.Join(ice.USR_LOCAL_WORK, value[mdb.NAME], ice.USR_PUBLISH, kit.Keys(ice.ICE, m.OptionDefault(cli.GOOS, cli.LINUX), m.OptionDefault(cli.GOARCH, cli.AMD64)))) @@ -44,7 +47,7 @@ func init() { m.Cmdy(web.SPACE, arg[0], web.SPACE, ice.MAIN) } else if kit.IsIn(arg[1], CMD, "c") { if kit.IsIn(arg[2], web.ADMIN) { - m.Cmdy(web.SPACE, arg[0], arg[2]) + m.Cmdy(web.SPACE, arg[0], arg[2], arg[3:]) } else { web.RenderPodCmd(m, arg[0], arg[2], arg[3:]) } diff --git a/core/code/bench.go b/core/code/bench.go index 943b147c..329d4bdf 100644 --- a/core/code/bench.go +++ b/core/code/bench.go @@ -12,7 +12,9 @@ import ( "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" + "shylinux.com/x/icebergs/base/web/html" kit "shylinux.com/x/toolkits" + "shylinux.com/x/toolkits/task" "shylinux.com/x/toolkits/util/bench" ) @@ -26,7 +28,11 @@ func _bench_http(m *ice.Message, target string, arg ...string) { } switch ls[0] { case http.MethodPost: - if f, e := nfs.OpenFile(m, ls[2]); m.Assert(e) { + if len(ls) == 2 { + if req, err := http.NewRequest(http.MethodPost, ls[1], nil); m.Assert(err) { + list = append(list, req) + } + } else if f, e := nfs.OpenFile(m, ls[2]); m.Assert(e) { defer f.Close() if req, err := http.NewRequest(http.MethodPost, ls[1], f); m.Assert(err) { list = append(list, req) @@ -42,12 +48,20 @@ func _bench_http(m *ice.Message, target string, arg ...string) { } }) var ndata int64 - if s, e := bench.HTTP(m.FormatTaskMeta(), nconn, nreqs, list, func(req *http.Request, res *http.Response) { - n, _ := io.Copy(ioutil.Discard, res.Body) - atomic.AddInt64(&ndata, n) - }); m.Assert(e) { - m.Echo("nconn: %d total: %d ndata: %s\n", nconn, nreqs*nconn, kit.FmtSize(ndata)).Echo(s.Show()).ProcessInner() - } + total, count := nreqs*nconn, 0 + var lock task.Lock + web.GoToast(m, m.Option(mdb.NAME), func(toast func(name string, count, total int)) []string { + if s, e := bench.HTTP(m.FormatTaskMeta(), nconn, nreqs, list, func(req *http.Request, res *http.Response) { + n, _ := io.Copy(ioutil.Discard, res.Body) + atomic.AddInt64(&ndata, n) + defer lock.Lock()() + toast(m.Option(mdb.NAME), count, int(total)) + count++ + }); m.Assert(e) { + m.Echo("nconn: %d total: %d ndata: %s\n", nconn, total, kit.FmtSize(ndata)).Echo(s.Show()).ProcessInner() + } + return nil + }) } func _bench_redis(m *ice.Message, target string, arg ...string) { } @@ -64,10 +78,18 @@ const BENCH = "bench" func init() { Index.MergeCommands(ice.Commands{ - BENCH: {Help: "压测", Actions: ice.MergeActions(ice.Actions{ + BENCH: {Help: "压测", Meta: kit.Dict( + ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(NCONN, "连接数", NREQS, "请求数")), + ), Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create zone*=demo"}, mdb.INSERT: {Name: "insert zone*=demo type*=http,redis name=demo text*='http://localhost:9020/chat/cmd/web.chat.favor' nconn=10 nreqs=100"}, cli.START: {Hand: func(m *ice.Message, arg ...string) { + if m.Option(mdb.ID) == "" { + m.Cmds("", m.Option(mdb.ZONE)).Table(func(value ice.Maps) { + m.Spawn(value).Cmd("", cli.START) + }) + return + } defer web.ToastProcess(m)() switch m.Option(mdb.TYPE) { case HTTP: @@ -76,8 +98,10 @@ func init() { _bench_redis(m, m.Option(mdb.TEXT)) } }}, - }, mdb.ZoneAction(mdb.FIELDS, "time,id,type,name,text,nconn,nreqs")), Hand: func(m *ice.Message, arg ...string) { - mdb.ZoneSelect(m, arg...).PushAction(kit.Select(cli.START, mdb.REMOVE, len(arg) == 0)) + }, mdb.ExportZoneAction(mdb.FIELDS, "time,id,type,name,text,nconn,nreqs")), Hand: func(m *ice.Message, arg ...string) { + mdb.ZoneSelect(m, arg...) + kit.If(len(arg) == 1, func() { m.Action(cli.START) }) + m.PushAction(kit.Select(cli.START, mdb.REMOVE, len(arg) == 0)) }}, }) }