From 59159a897aef1aa9dcbd5788d8a485cf48ef15a8 Mon Sep 17 00:00:00 2001 From: shy Date: Sat, 16 Mar 2024 19:56:46 +0800 Subject: [PATCH] opt some --- base/cli/runtime.go | 6 +----- base/gdb/gdb.go | 13 +++++-------- base/gdb/signal.go | 2 +- base/web/dream.go | 2 +- base/web/serve.go | 8 ++++++++ base/web/space.go | 1 + base/web/spide.go | 8 -------- info.go | 1 - 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/base/cli/runtime.go b/base/cli/runtime.go index f4161418..0118cb65 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -29,11 +29,7 @@ func _runtime_init(m *ice.Message) { m.Conf(RUNTIME, kit.Keys(HOST, HOME), kit.HomePath("")) m.Conf(RUNTIME, kit.Keys(HOST, MAXPROCS), runtime.GOMAXPROCS(0)) ice.Info.System = m.Conf(RUNTIME, kit.Keys(HOST, OSID)) - ice.Info.PidPath = ice.VAR_LOG_ICE_PID - kit.For(ENV_LIST, func(k string) { - m.Conf(RUNTIME, kit.Keys(CONF, k), kit.Env(k)) - kit.If(k == CTX_PID, func() { ice.Info.PidPath = kit.Env(k) }) - }) + kit.For(ENV_LIST, func(k string) { m.Conf(RUNTIME, kit.Keys(CONF, k), kit.Env(k)) }) ice.Info.Lang = m.Conf(RUNTIME, kit.Keys(CONF, LANG)) m.Conf(RUNTIME, kit.Keys(BOOT, USERNAME), kit.UserName()) m.Conf(RUNTIME, kit.Keys(BOOT, HOSTNAME), kit.Env("HOSTNAME")) diff --git a/base/gdb/gdb.go b/base/gdb/gdb.go index b4b889d2..ce145601 100644 --- a/base/gdb/gdb.go +++ b/base/gdb/gdb.go @@ -19,13 +19,11 @@ func (f *Frame) Begin(m *ice.Message, arg ...string) { f.s = make(chan os.Signal, 10) } func (f *Frame) Start(m *ice.Message, arg ...string) { - kit.If(ice.Info.PidPath, func(p string) { - if f, p, e := logs.CreateFile(p); e == nil { - defer f.Close() - m.Logs("save", "file", p, PID, os.Getpid()) - fmt.Fprint(f, os.Getpid()) - } - }) + if f, p, e := logs.CreateFile(ice.VAR_LOG_ICE_PID); e == nil { + m.Logs("save", "file", p, PID, os.Getpid()) + fmt.Fprint(f, os.Getpid()) + f.Close() + } t := time.NewTicker(kit.Duration(mdb.Conf(m, TIMER, kit.Keym(TICK)))) for { select { @@ -41,7 +39,6 @@ func (f *Frame) Start(m *ice.Message, arg ...string) { } func (f *Frame) Close(m *ice.Message, arg ...string) { close(f.s) - kit.If(ice.Info.PidPath, func(p string) { os.Remove(p) }) } func (f *Frame) listen(m *ice.Message, s int, arg ...string) { signal.Notify(f.s, syscall.Signal(s)) diff --git a/base/gdb/signal.go b/base/gdb/signal.go index 53298095..7c437e6e 100644 --- a/base/gdb/signal.go +++ b/base/gdb/signal.go @@ -20,7 +20,7 @@ func _signal_action(m *ice.Message, arg ...string) { mdb.HashSelect(m.Spawn(), arg...).Table(func(value ice.Maps) { m.Cmdy(kit.Split(value[ice.CMD])) }) } func _signal_process(m *ice.Message, p string, s os.Signal) { - kit.If(p == "", func() { b, _ := file.ReadFile(ice.Info.PidPath); p = string(b) }) + kit.If(p == "", func() { b, _ := file.ReadFile(ice.VAR_LOG_ICE_PID); p = string(b) }) if p, e := os.FindProcess(kit.Int(kit.Select(kit.Format(os.Getpid()), p))); e == nil { p.Signal(s) } diff --git a/base/web/dream.go b/base/web/dream.go index 42119a7c..abe4242e 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -147,7 +147,7 @@ func _dream_start(m *ice.Message, name string) { } defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "") m.Options(cli.CMD_DIR, kit.Path(p), cli.CMD_ENV, kit.EnvList(kit.Simple(m.OptionSimple(ice.TCP_DOMAIN), - cli.CTX_OPS, HostPort(m, tcp.LOCALHOST, m.Cmdv(SERVE, tcp.PORT)), cli.CTX_LOG, ice.VAR_LOG_BOOT_LOG, cli.CTX_PID, ice.VAR_LOG_ICE_PID, + cli.CTX_OPS, HostPort(m, tcp.LOCALHOST, m.Cmdv(SERVE, tcp.PORT)), cli.CTX_LOG, ice.VAR_LOG_BOOT_LOG, cli.CTX_ROOT, kit.Path(""), cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username, )...), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG), mdb.CACHE_CLEAR_ONEXIT, ice.TRUE) kit.If(m.Option(nfs.BINARY) == "" && !cli.SystemFindGo(m), func(p string) { m.Option(nfs.BINARY, S(name)) }) diff --git a/base/web/serve.go b/base/web/serve.go index ca250682..293a1826 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -252,6 +252,14 @@ func init() { m.Cmd(cli.SYSTEM, "sudo", PROXY_CMDS, "-s", "reload", kit.Dict(cli.CMD_DIR, dir)) } } + if m.Cmd(tcp.HOST).Length() == 0 { + return + } + m.Cmds(SPIDE).Table(func(value ice.Maps) { + kit.If(value[TOKEN], func() { + m.Cmd(SPACE, tcp.DIAL, ice.DEV, value[CLIENT_NAME], TOKEN, value[TOKEN], mdb.TYPE, SERVER) + }) + }) }}, PROXY_CONF: {Name: "proxyConf name* port host path", Hand: func(m *ice.Message, arg ...string) { if dir := m.OptionDefault(nfs.PATH, PROXY_PATH, tcp.HOST, "127.0.0.1", tcp.PORT, "9020"); nfs.Exists(m, dir) { diff --git a/base/web/space.go b/base/web/space.go index 8fa77e40..1268fda1 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -194,6 +194,7 @@ func _space_exec(m *ice.Message, name string, source, target []string, c *websoc return } m.OptionDefault(ice.MSG_COUNT, "0") + m.Option(ice.MSG_ARGS, "") kit.If(m.Option(ice.MSG_DAEMON), func(p string) { m.Option(ice.MSG_DAEMON0, m.Option(ice.MSG_DAEMON)) m.Option(ice.MSG_DAEMON, kit.Keys(kit.Slice(kit.Reverse(kit.Simple(source)), 0, -1), p)) diff --git a/base/web/spide.go b/base/web/spide.go index 69012f32..98ca73e5 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -290,14 +290,6 @@ func init() { m.Cmd("", mdb.CREATE, ice.OPS, kit.Select("http://localhost:9020", conf[cli.CTX_OPS]), nfs.REPOS, nfs.USR_ICONS_CONTEXTS) 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 { - return - } - mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) { - kit.If(value[TOKEN], func() { - m.Cmd(SPACE, tcp.DIAL, ice.DEV, value[CLIENT_NAME], TOKEN, value[TOKEN], mdb.TYPE, SERVER) - }) - }) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { diff --git a/info.go b/info.go index d6c966c3..7049e684 100644 --- a/info.go +++ b/info.go @@ -68,7 +68,6 @@ type info struct { Lang string System string Domain string - PidPath string CtxRoot string Traceid string Localhost bool