1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00

add sleep

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-12-05 23:17:43 +08:00
parent 8dc2aaa35b
commit a16b7e9c3a
13 changed files with 32 additions and 26 deletions

View File

@ -101,7 +101,9 @@ func insert(m *ice.Message, sys, cmd string, arg ...string) bool {
return false
}
if len(arg) > 0 {
m.GoSleep("300ms", mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, sys, CMD, cmd+lex.SP+kit.Select(arg[0], arg, 1))
m.GoSleep300ms(func() {
m.Cmd(mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, sys, CMD, cmd+lex.SP+kit.Select(arg[0], arg, 1))
})
}
return true
}

View File

@ -20,8 +20,10 @@ func _broad_send(m *ice.Message, to_host, to_port string, host, port string, arg
})
}
func _broad_serve(m *ice.Message) {
m.GoSleep("30ms", tcp.HOST, func(value ice.Maps) {
_broad_send(m, "", "", value[aaa.IP], m.Option(tcp.PORT), gdb.EVENT, tcp.LISTEN, mdb.NAME, ice.Info.NodeName, mdb.TYPE, ice.Info.NodeType)
m.GoSleep300ms(func() {
m.Cmd(tcp.HOST, func(value ice.Maps) {
_broad_send(m, "", "", value[aaa.IP], m.Option(tcp.PORT), gdb.EVENT, tcp.LISTEN, mdb.NAME, ice.Info.NodeName, mdb.TYPE, ice.Info.NodeType)
})
})
m.Cmd(tcp.SERVER, tcp.LISTEN, mdb.TYPE, tcp.UDP4, mdb.NAME, logs.FileLine(1), m.OptionSimple(tcp.HOST, tcp.PORT), func(from *net.UDPAddr, buf []byte) {
msg := m.Spawn(buf).Logs(tcp.RECV, BROAD, string(buf), nfs.FROM, from)

View File

@ -139,8 +139,7 @@ func init() {
DREAM: {Name: "dream name@key auto create repos startall stopall publish cmd cat", Help: "梦想家", Icon: "Launchpad.png", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m = m.Spawn()
m.Go(func() {
m.Sleep("10s")
m.GoSleep("10s", func() {
mdb.HashSelects(m).Table(func(value ice.Maps) {
if value[cli.RESTART] == "always" && nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK+value[mdb.NAME])) {
m.Cmd(DREAM, cli.START, kit.Dict(mdb.NAME, value[mdb.NAME]))
@ -254,7 +253,7 @@ func init() {
}},
DREAM_CLOSE: {Hand: func(m *ice.Message, arg ...string) {
if m.Option(cli.DAEMON) == ice.OPS && m.Cmdv(SPACE, m.Option(mdb.NAME), mdb.STATUS) != cli.STOP {
m.Go(func() { m.Sleep300ms(DREAM, cli.START, m.OptionSimple(mdb.NAME)) })
m.GoSleep300ms(func() { m.Cmd(DREAM, cli.START, m.OptionSimple(mdb.NAME)) })
}
}},
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {

View File

@ -84,7 +84,7 @@ func init() {
}},
cli.BUILD: {Name: "build space", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
_route_toast(m, m.Option(SPACE), m.PrefixKey(), "_build")
func() { defer ToastProcess(m)(); m.Sleep("3s") }()
func() { defer ToastProcess(m)(); m.Sleep3s() }()
m.Cmdy("", "travel")
}},
"_build": {Hand: func(m *ice.Message, arg ...string) {

View File

@ -20,9 +20,9 @@ func init() {
Index.MergeCommands(ice.Commands{
GRANT: {Name: "grant space auto", Help: "授权", Actions: ice.MergeActions(ice.Actions{
web.SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
m.Go(func() {
m.GoSleep30ms(func() {
link := tcp.PublishLocalhost(m, m.MergePodCmd("", "", web.SPACE, m.Option(mdb.NAME)))
m.Sleep30ms(web.SPACE, m.Option(mdb.NAME), cli.PWD, m.Option(mdb.NAME), link, m.Cmdx(cli.QRCODE, link))
m.Cmd(web.SPACE, m.Option(mdb.NAME), cli.PWD, m.Option(mdb.NAME), link, m.Cmdx(cli.QRCODE, link))
})
}},
web.HOME: {Help: "首页", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(web.MergeLink(m, web.CHAT_PORTAL)) }},

View File

@ -179,7 +179,7 @@ func init() {
cmds = []string{COMPILE, ice.SRC_WEBVIEW_GO, path.Join(app, _app)}
}
if msg := m.Cmd(cmds); cli.IsSuccess(msg) {
if m.Go(func() { m.Sleep30ms().Cmd(UPGRADE, cli.RESTART) }); isWebview() {
if m.GoSleep30ms(func() { m.Cmd(UPGRADE, cli.RESTART) }); isWebview() {
m.Cmd(cli.DAEMON, "./bin/ice.bin", cli.FOREVER, cli.DELAY, "300ms", cli.SYSTEM, cli.OPEN, app)
}
} else {

View File

@ -41,7 +41,7 @@ func _xterm_get(m *ice.Message, h string) xterm.XTerm {
for {
if n, e := term.Read(buf); !m.Warn(e) && e == nil {
if _xterm_echo(m, h, string(buf[:n])); len(text) > 0 {
kit.If(text[0], func(cmd string) { m.Go(func() { m.Sleep300ms(); term.Write([]byte(cmd + lex.NL)) }) })
kit.If(text[0], func(cmd string) { m.GoSleep300ms(func() { term.Write([]byte(cmd + lex.NL)) }) })
text = text[1:]
}
} else {

View File

@ -57,9 +57,12 @@ func (m *Message) Sleep(d Any, arg ...Any) *Message {
func (m *Message) Sleep300ms(arg ...Any) *Message { return m.Sleep("300ms", arg...) }
func (m *Message) Sleep30ms(arg ...Any) *Message { return m.Sleep("30ms", arg...) }
func (m *Message) Sleep3s(arg ...Any) *Message { return m.Sleep("3s", arg...) }
func (m *Message) GoSleep(t string, arg ...Any) {
m.Go(func() { m.Spawn(kit.Dict(MSG_COUNT, "0")).Sleep(t).Cmd(arg...) })
func (m *Message) GoSleep(t string, cb func(), arg ...Any) {
m.Go(func() { m.Spawn(kit.Dict(MSG_COUNT, "0")).Sleep(t); cb() })
}
func (m *Message) GoSleep300ms(cb func(), arg ...Any) { m.GoSleep("300ms", cb, arg...) }
func (m *Message) GoSleep30ms(cb func(), arg ...Any) { m.GoSleep("30ms", cb, arg...) }
func (m *Message) GoSleep3s(cb func(), arg ...Any) { m.GoSleep("3s", cb, arg...) }
func (m *Message) Go(cb func(), arg ...Any) *Message {
meta := m.FormatTaskMeta()
meta.FileLine = kit.FileLine(2, 3)

View File

@ -59,11 +59,10 @@ var Index = &Context{Name: ICE, Help: "冰山模块", Commands: Commands{
loadImportant(m)
}},
QUIT: {Hand: func(m *Message, arg ...string) {
m.Go(func() { m.Sleep30ms(); os.Exit(kit.Int(kit.Select("0", arg, 0))) })
m.GoSleep300ms(func() { os.Exit(kit.Int(kit.Select("0", arg, 0))) })
}},
EXIT: {Hand: func(m *Message, arg ...string) {
m.Go(func() {
m.Sleep30ms()
m.GoSleep300ms(func() {
m.root.Option(EXIT, kit.Select("0", arg, 0))
m.Cmd(SOURCE, ETC_EXIT_SHY)
m.Cmd(CTX_EXIT)

View File

@ -91,7 +91,7 @@ func _ssh_dial(m *ice.Message, cb func(net.Conn), arg ...string) {
}
}, arg...)
}
func _ssh_conn(m *ice.Message, cb func(*ssh.Client), arg ...string) {
func _ssh_conn(m *ice.Message, cb func(*ssh.Client), arg ...string) (err error) {
methods := []ssh.AuthMethod{}
methods = append(methods, ssh.PublicKeysCallback(func() ([]ssh.Signer, error) {
key, err := ssh.ParsePrivateKey([]byte(m.Cmdx(nfs.CAT, kit.HomePath(m.OptionDefault(PRIVATE, ID_RSA_KEY)))))
@ -117,12 +117,14 @@ func _ssh_conn(m *ice.Message, cb func(*ssh.Client), arg ...string) {
return
}))
m.Cmd(tcp.CLIENT, tcp.DIAL, mdb.TYPE, SSH, mdb.NAME, m.Option(tcp.HOST), m.OptionSimple(tcp.HOST, tcp.PORT), arg, func(c net.Conn) {
conn, chans, reqs, err := ssh.NewClientConn(c, m.Option(tcp.HOST)+nfs.DF+m.Option(tcp.PORT), &ssh.ClientConfig{
conn, chans, reqs, _err := ssh.NewClientConn(c, m.Option(tcp.HOST)+nfs.DF+m.Option(tcp.PORT), &ssh.ClientConfig{
User: m.Option(aaa.USERNAME), Auth: methods, BannerCallback: func(message string) error { return nil },
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { return nil },
})
kit.If(!m.Warn(err), func() { cb(ssh.NewClient(conn, chans, reqs)) })
kit.If(!m.Warn(_err), func() { cb(ssh.NewClient(conn, chans, reqs)) })
err = _err
})
return
}
func _ssh_hold(m *ice.Message, c *ssh.Client) {
if s, e := _ssh_session(m, c); !m.Warn(e, ice.ErrNotValid) {

View File

@ -25,8 +25,8 @@ func (s XTerm) Close() error {
return s.Session.Close()
}
func Shell(m *ice.Message, cb func(xterm.XTerm)) {
_ssh_conn(m, func(c *ssh.Client) {
func Shell(m *ice.Message, cb func(xterm.XTerm)) error {
return _ssh_conn(m, func(c *ssh.Client) {
if s, e := c.NewSession(); !m.Warn(e, ice.ErrNotValid) {
defer s.Close()
w, _ := s.StdinPipe()

View File

@ -107,8 +107,7 @@ func init() {
if !cli.IsSuccess(_tmux_cmd(m, SPLIT_WINDOW, "-t", kit.Keys(name, "1"), "-p", "40")) {
return
}
m.Go(func() {
m.Sleep300ms()
m.GoSleep300ms(func() {
_tmux_cmd(m, SEND_KEYS, "-t", kit.Keys(name, "2"), "ish_miss_log", ENTER)
_tmux_cmd(m, SEND_KEYS, "-t", kit.Keys(name, "1"), "vi etc/miss.sh", ENTER)
})
@ -159,8 +158,8 @@ func init() {
}).Sleep30ms()
}},
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
m.Go(func() {
nfs.Exists(m.Sleep3s(), path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)), func(p string) { m.Cmd("", mdb.CREATE) })
m.GoSleep3s(func() {
nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)), func(p string) { m.Cmd("", mdb.CREATE) })
})
}},
}, Hand: func(m *ice.Message, arg ...string) {

View File

@ -60,7 +60,7 @@ func init() {
}},
aaa.LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) {
p := nfs.TempName(m)
m.Go(func() { web.PushNoticeGrow(m.Sleep("1s"), ice.Render(m, ice.RENDER_IMAGES, web.SHARE_LOCAL+p)) })
m.GoSleep("1s", func() { web.PushNoticeGrow(m, ice.Render(m, ice.RENDER_IMAGES, web.SHARE_LOCAL+p)) })
IdeCli(m, "", _ide_args_cli(m), _ide_args_qrcode(m, p)).ProcessRefresh()
}},
web.ADMIN: {Help: "后台", Hand: func(m *ice.Message, arg ...string) {