From 0f6111bbeace1a891b96b1cf27d741426afcea5e Mon Sep 17 00:00:00 2001 From: shylinux Date: Fri, 24 Mar 2023 16:08:09 +0800 Subject: [PATCH] opt some --- base/ssh/script.go | 3 --- base/web/serve.go | 10 ++++++---- init.go | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/base/ssh/script.go b/base/ssh/script.go index 3070d211..f1f58ba4 100644 --- a/base/ssh/script.go +++ b/base/ssh/script.go @@ -107,9 +107,6 @@ func (f *Frame) scan(m *ice.Message, h, line string) *Frame { f.ps2 = kit.Simple(mdb.Confv(m, PROMPT, kit.Keym(PS2))) // m.Options(MESSAGE, m, ice.LOG_DISABLE, ice.TRUE) m.I, m.O = f.stdin, f.stdout - if msg := m.Cmd("serve"); msg.Append("status") == "start" { - m.Cmd(PRINTF, kit.Dict(nfs.CONTENT, ice.NL+ice.Render(m, ice.RENDER_QRCODE, tcp.PublishLocalhost(m, kit.Format("http://localhost:%s", msg.Append(tcp.PORT)))))) - } ps, bio := f.ps1, bufio.NewScanner(f.stdin) for f.prompt(m, ps...); f.stdin != nil && bio.Scan(); f.prompt(m, ps...) { if len(bio.Text()) == 0 && h == STDIO { diff --git a/base/web/serve.go b/base/web/serve.go index 018ae025..497e64a0 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -17,6 +17,7 @@ import ( "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" + "shylinux.com/x/icebergs/base/ssh" "shylinux.com/x/icebergs/base/tcp" kit "shylinux.com/x/toolkits" ) @@ -191,13 +192,14 @@ func init() { }}, SERVE_START: {Hand: func(m *ice.Message, arg ...string) { m.Go(func() { + msg := m.Spawn(kit.Dict(ice.LOG_DISABLE, ice.TRUE)).Sleep("10ms") + msg.Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, ice.NL+ice.Render(msg, ice.RENDER_QRCODE, tcp.PublishLocalhost(msg, kit.Format("http://localhost:%s", msg.Option(tcp.PORT)))))) + msg.Cmd(ssh.PROMPT) opened := false for i := 0; i < 3 && !opened; i++ { - m.Sleep("1s").Cmd(SPACE, kit.Dict(ice.LOG_DISABLE, ice.TRUE), func(values ice.Maps) { - kit.If(values[mdb.TYPE] == CHROME, func() { opened = true }) - }) + msg.Sleep("1s").Cmd(SPACE, func(values ice.Maps) { kit.If(values[mdb.TYPE] == CHROME, func() { opened = true }) }) } - kit.If(!opened, func() { cli.Opens(m, _serve_address(m)) }) + kit.If(!opened, func() { cli.Opens(msg, _serve_address(msg)) }) }) }}, DOMAIN: {Hand: func(m *ice.Message, arg ...string) { diff --git a/init.go b/init.go index 831fd8ad..e04c811a 100644 --- a/init.go +++ b/init.go @@ -26,7 +26,7 @@ func (s *Frame) Begin(m *Message, arg ...string) { func (s *Frame) Start(m *Message, arg ...string) { m.Cmd(INIT, arg) kit.For(kit.Split(kit.Select(kit.Join([]string{LOG, GDB, SSH}), os.Getenv(CTX_DAEMON))), func(k string) { m.Sleep("10ms").Start(k) }) - m.Cmd(arg) + m.Sleep("10ms").Cmd(arg) } func (s *Frame) Close(m *Message, arg ...string) { list := map[*Context]*Message{m.target: m}