From 1abaf50c4062efd46046d6dca8a5a3e888041e45 Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 18 Mar 2024 13:28:05 +0800 Subject: [PATCH] add some --- base/cli/system.go | 2 ++ base/nfs/dir.go | 1 + base/web/serve.go | 2 +- base/web/space.go | 2 ++ base/web/spide.go | 1 + core/code/publish.go | 12 ++++++------ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/base/cli/system.go b/base/cli/system.go index f699dc74..296dd58e 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -143,10 +143,12 @@ const ( CMD_OUT = "cmd_out" SH = "sh" + RM = "rm" GO = "go" GIT = "git" WGET = "wget" CURL = "curl" + TAIL = "tail" MAN = "man" RUN = "run" KILL = "kill" diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 3d74e3fe..7b1ba502 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -157,6 +157,7 @@ const ( USR_MODULES = "usr/node_modules/" USR_PACKAGE = "usr/package.json" + VAR_LOG_BENCH_LOG = "var/log/bench.log" USR_ICONS_AVATAR = "usr/icons/avatar.jpg" USR_ICONS_CONTEXTS = "usr/icons/contexts.jpg" USR_ICONS_ICEBERGS = "usr/icons/icebergs.png" diff --git a/base/web/serve.go b/base/web/serve.go index 4b1fa89a..b3586448 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -34,7 +34,7 @@ func _serve_start(m *ice.Message) { m.Go(func() { m.Cmd(SPIDE, ice.OPS, _serve_address(m)+"/exit", ice.Maps{CLIENT_TIMEOUT: cli.TIME_30ms, ice.LOG_DISABLE: ice.TRUE}) }).Sleep(cli.TIME_1s) - m.Start("", m.OptionSimple(tcp.HOST, tcp.PORT)...) + m.Spawn(ice.Maps{TOKEN: ""}).Start("", m.OptionSimple(tcp.HOST, tcp.PORT)...) m.Cmd(nfs.SAVE, ice.VAR_LOG_ICE_PORT, m.Option(tcp.PORT)) if m.Cmd(tcp.HOST).Length() == 0 { return diff --git a/base/web/space.go b/base/web/space.go index 26c9981b..591ca75f 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -345,6 +345,8 @@ func init() { m.Push(nfs.MODULE, ice.Info.Make.Module) m.Push(nfs.VERSION, ice.Info.Make.Versions()) m.Push(ORIGIN, m.Option(ice.MSG_USERHOST)) + m.Push("hostport", UserHost(m)) + m.Push("pathname", ice.Info.Pathname) }}, nfs.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }}, }, gdb.EventsAction(SPACE_LOGIN), mdb.HashAction( diff --git a/base/web/spide.go b/base/web/spide.go index db9b82da..109f088c 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -446,6 +446,7 @@ func HostPort(m *ice.Message, host, port string, arg ...string) string { kit.If(kit.Select("", arg, 0), func(pod string) { p += S(pod) }) kit.If(kit.Select("", arg, 1), func(cmd string) { p += C(cmd) }) } + kit.If(m.Option(ice.LOG_DEBUG) == ice.TRUE, func() { p += "?debug=true" }) kit.If(host == "", func() { host = kit.ParseURL(UserHost(m)).Hostname() }) if port == tcp.PORT_443 { return kit.Format("https://%s", host) + p diff --git a/core/code/publish.go b/core/code/publish.go index 944621f0..e9049b08 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -45,11 +45,12 @@ func _publish_file(m *ice.Message, file string, arg ...string) string { return m.Cmdx(nfs.LINK, path.Join(ice.USR_PUBLISH, kit.Select(path.Base(file), arg, 0)), file) } func _publish_contexts(m *ice.Message, arg ...string) { - // m.Options(nfs.DIR_ROOT, "") m.OptionDefault(web.DOMAIN, tcp.PublishLocalhost(m, web.UserHost(m))) m.OptionDefault(cli.CTX_CLI, "temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp") m.OptionDefault(cli.CTX_ARG, kit.JoinCmdArgs(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.LANGUAGE, m.Option(ice.MSG_LANGUAGE))) - for _, k := range kit.Default(arg, ice.MISC) { + m.Option(web.DOMAIN, strings.Split(m.Option(web.DOMAIN), "?")[0]) + msg := web.AdminCmd(m, web.SPACE, "info") + for _, k := range kit.Default(arg, ice.APP) { env := []string{} switch k { case nfs.SOURCE, ice.DEV: @@ -63,13 +64,12 @@ func _publish_contexts(m *ice.Message, arg ...string) { env = append(env, cli.CTX_REPOS, m.Option(nfs.SOURCE)) fallthrough case nfs.BINARY, ice.APP: - if host := web.HostPort(m, web.AdminCmd(m, tcp.HOST).Append(aaa.IP), web.AdminCmd(m, web.SERVE).Append(tcp.PORT)); m.Option(web.DOMAIN) != host { - env = append(env, cli.CTX_DEV_IP, host) + if host := msg.Append("hostport"); m.Option(web.DOMAIN) != host { + env = append(env, cli.CTX_DEV_IP, strings.Split(host, "?")[0]) } - // if ice.Info.NodeType == web.WORKER && m.Option(ice.MSG_USERPOD) != "" { if m.Option(ice.MSG_USERPOD) != "" { env = append(env, cli.CTX_POD, m.Option(ice.MSG_USERPOD)) - } else if name := web.AdminCmd(m, cli.RUNTIME, "boot.pathname").Result(); !kit.IsIn(name, path.Base(m.Option(nfs.SOURCE)), ice.CONTEXTS) { + } else if name := msg.Append("pathname"); !kit.IsIn(name, path.Base(m.Option(nfs.SOURCE)), ice.CONTEXTS) { env = append(env, "ctx_name", name) } case cli.CURL, cli.WGET: