mirror of
https://shylinux.com/x/icebergs
synced 2025-04-28 10:12:02 +08:00
opt some
This commit is contained in:
parent
93e32aa8a0
commit
d86c6db791
@ -153,7 +153,6 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,path,chain auto upgrade", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
|
RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,path,chain auto upgrade", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", "", nil) }},
|
|
||||||
IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }},
|
IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }},
|
||||||
HOSTINFO: {Hand: func(m *ice.Message, arg ...string) { _runtime_hostinfo(m) }},
|
HOSTINFO: {Hand: func(m *ice.Message, arg ...string) { _runtime_hostinfo(m) }},
|
||||||
HOSTNAME: {Hand: func(m *ice.Message, arg ...string) {
|
HOSTNAME: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -64,7 +64,7 @@ func init() {
|
|||||||
if f, p, e := logs.CreateFile(ice.Info.PidPath); e == nil {
|
if f, p, e := logs.CreateFile(ice.Info.PidPath); e == nil {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
fmt.Fprint(f, os.Getpid())
|
fmt.Fprint(f, os.Getpid())
|
||||||
m.Logs(mdb.CREATE, PID, p)
|
m.Logs("save", PID, p)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
LISTEN: {Name: "listen signal name cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
LISTEN: {Name: "listen signal name cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -15,12 +15,13 @@ const DEBUG = "debug"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
DEBUG: {Name: "debug level=watch,bench,watch,error,trace offset filter auto doc", Help: "后台日志", Actions: ice.Actions{
|
DEBUG: {Name: "debug level=watch,bench,debug,error,watch offset filter auto doc", Help: "后台日志", Actions: ice.Actions{
|
||||||
"doc": {Help: "文档", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen("https://pkg.go.dev/std") }},
|
"doc": {Help: "文档", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen("https://pkg.go.dev/std") }},
|
||||||
}, Hand: func(m *ice.Message, arg ...string) {
|
}, Hand: func(m *ice.Message, arg ...string) {
|
||||||
offset := kit.Int(kit.Select("0", arg, 1))
|
offset := kit.Int(kit.Select("0", arg, 1))
|
||||||
|
stats := map[string]int{}
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "bench", ERROR, "trace":
|
case BENCH, ERROR, DEBUG:
|
||||||
m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(line string, index int) {
|
m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(line string, index int) {
|
||||||
if len(arg) > 2 && !strings.Contains(line, arg[2]) || index < offset {
|
if len(arg) > 2 && !strings.Contains(line, arg[2]) || index < offset {
|
||||||
return
|
return
|
||||||
@ -29,12 +30,12 @@ func init() {
|
|||||||
m.Push(mdb.TIME, ls[0]+ice.SP+ls[1])
|
m.Push(mdb.TIME, ls[0]+ice.SP+ls[1])
|
||||||
m.Push(mdb.ID, ls[2])
|
m.Push(mdb.ID, ls[2])
|
||||||
i := strings.LastIndex(ls[5], ice.SP)
|
i := strings.LastIndex(ls[5], ice.SP)
|
||||||
if strings.HasPrefix(ls[5][i+1:], "base") || strings.HasPrefix(ls[5][i+1:], "core") || strings.HasPrefix(ls[5][i+1:], "misc") {
|
if strings.HasPrefix(ls[5][i+1:], ice.BASE) || strings.HasPrefix(ls[5][i+1:], ice.CORE) || strings.HasPrefix(ls[5][i+1:], ice.MISC) {
|
||||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||||
m.Push(nfs.FILE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[0]))
|
m.Push(nfs.FILE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[0]))
|
||||||
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[1]))
|
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[1]))
|
||||||
ls[5] = ls[5][:i]
|
ls[5] = ls[5][:i]
|
||||||
} else if strings.HasPrefix(ls[5][i+1:], "usr/icebergs/") {
|
} else if strings.HasPrefix(ls[5][i+1:], ice.USR_ICEBERGS) {
|
||||||
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
m.Push(nfs.PATH, ice.USR_ICEBERGS)
|
||||||
m.Push(nfs.FILE, strings.TrimPrefix(strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[0]), ice.USR_ICEBERGS))
|
m.Push(nfs.FILE, strings.TrimPrefix(strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[0]), ice.USR_ICEBERGS))
|
||||||
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[1]))
|
m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[5][i:], ice.DF)[1]))
|
||||||
@ -57,6 +58,7 @@ func init() {
|
|||||||
m.Push("ship", ls[3])
|
m.Push("ship", ls[3])
|
||||||
m.Push(ctx.ACTION, ls[4])
|
m.Push(ctx.ACTION, ls[4])
|
||||||
m.Push(mdb.TEXT, ls[5])
|
m.Push(mdb.TEXT, ls[5])
|
||||||
|
stats[ls[4]]++
|
||||||
})
|
})
|
||||||
case WATCH:
|
case WATCH:
|
||||||
m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(line string, index int) {
|
m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(line string, index int) {
|
||||||
@ -75,9 +77,10 @@ func init() {
|
|||||||
|
|
||||||
m.Push(ctx.ACTION, ls[4])
|
m.Push(ctx.ACTION, ls[4])
|
||||||
m.Push(mdb.TEXT, ls[5][:i])
|
m.Push(mdb.TEXT, ls[5][:i])
|
||||||
|
stats[ls[4]]++
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
m.StatusTimeCountTotal(offset + m.Length())
|
m.StatusTimeCountTotal(offset+m.Length(), stats)
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ var Index = &ice.Context{Name: LOG, Help: "日志模块", Configs: ice.Configs{
|
|||||||
if f, p, e := logs.CreateFile(kit.Format(value[nfs.PATH])); e == nil {
|
if f, p, e := logs.CreateFile(kit.Format(value[nfs.PATH])); e == nil {
|
||||||
m.Cap(ice.CTX_STREAM, path.Base(p))
|
m.Cap(ice.CTX_STREAM, path.Base(p))
|
||||||
value[FILE] = bufio.NewWriter(f)
|
value[FILE] = bufio.NewWriter(f)
|
||||||
m.Logs(mdb.CREATE, nfs.FILE, p)
|
m.Logs(nfs.SAVE, nfs.FILE, p)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
m.Confm(VIEW, nil, func(key string, value ice.Map) {
|
m.Confm(VIEW, nil, func(key string, value ice.Map) {
|
||||||
|
@ -68,7 +68,7 @@ func _cat_list(m *ice.Message, file string) {
|
|||||||
buf, size := make([]byte, 10*ice.MOD_BUFS), 0
|
buf, size := make([]byte, 10*ice.MOD_BUFS), 0
|
||||||
for {
|
for {
|
||||||
if n, e := f.Read(buf[size:]); !m.Warn(e, ice.ErrNotValid, file) {
|
if n, e := f.Read(buf[size:]); !m.Warn(e, ice.ErrNotValid, file) {
|
||||||
m.Logs(mdb.IMPORT, FILE, file, SIZE, n)
|
m.Logs(LOAD, FILE, file, SIZE, n)
|
||||||
if size += n; size < len(buf) {
|
if size += n; size < len(buf) {
|
||||||
buf = buf[:size]
|
buf = buf[:size]
|
||||||
break
|
break
|
||||||
|
@ -10,6 +10,10 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SEND = "send"
|
||||||
|
RECV = "recv"
|
||||||
|
)
|
||||||
const TCP = "tcp"
|
const TCP = "tcp"
|
||||||
|
|
||||||
var Index = &ice.Context{Name: TCP, Help: "通信模块"}
|
var Index = &ice.Context{Name: TCP, Help: "通信模块"}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"shylinux.com/x/icebergs/base/aaa"
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
"shylinux.com/x/icebergs/base/tcp"
|
"shylinux.com/x/icebergs/base/tcp"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
"shylinux.com/x/toolkits/logs"
|
"shylinux.com/x/toolkits/logs"
|
||||||
@ -23,7 +24,7 @@ func _broad_send(m *ice.Message, host, port string, remote_host, remote_port str
|
|||||||
if s, e := net.DialUDP("udp4", nil, _broad_addr(m, remote_host, remote_port)); !m.Warn(e, ice.ErrNotValid) {
|
if s, e := net.DialUDP("udp4", nil, _broad_addr(m, remote_host, remote_port)); !m.Warn(e, ice.ErrNotValid) {
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
msg := m.Spawn(kit.Dict(tcp.HOST, host, tcp.PORT, port), kit.Dict(arg))
|
msg := m.Spawn(kit.Dict(tcp.HOST, host, tcp.PORT, port), kit.Dict(arg))
|
||||||
m.Logs(mdb.EXPORT, BROAD, msg.FormatMeta(), "to", remote_host+ice.DF+remote_port)
|
m.Logs(tcp.SEND, BROAD, msg.FormatMeta(), nfs.TO, remote_host+ice.DF+remote_port)
|
||||||
s.Write([]byte(msg.FormatMeta()))
|
s.Write([]byte(msg.FormatMeta()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +42,7 @@ func _broad_serve(m *ice.Message, port string) {
|
|||||||
if e != nil {
|
if e != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
m.Logs(mdb.IMPORT, BROAD, string(buf[:n]), "from", from)
|
m.Logs(tcp.RECV, BROAD, string(buf[:n]), nfs.FROM, from)
|
||||||
msg := m.Spawn(buf[:n])
|
msg := m.Spawn(buf[:n])
|
||||||
if msg.Option(mdb.ZONE) == "echo" {
|
if msg.Option(mdb.ZONE) == "echo" {
|
||||||
_broad_save(m, msg)
|
_broad_save(m, msg)
|
||||||
@ -49,7 +50,7 @@ func _broad_serve(m *ice.Message, port string) {
|
|||||||
}
|
}
|
||||||
if remote := _broad_addr(m, msg.Option(tcp.HOST), msg.Option(tcp.PORT)); remote != nil {
|
if remote := _broad_addr(m, msg.Option(tcp.HOST), msg.Option(tcp.PORT)); remote != nil {
|
||||||
m.Cmd(BROAD, func(value ice.Maps) {
|
m.Cmd(BROAD, func(value ice.Maps) {
|
||||||
m.Logs(mdb.EXPORT, BROAD, kit.Format(value), "to", kit.Format(remote))
|
m.Logs(tcp.SEND, BROAD, kit.Format(value), nfs.TO, kit.Format(remote))
|
||||||
s.WriteToUDP([]byte(m.Spawn(value, kit.Dict(mdb.ZONE, "echo")).FormatMeta()), remote)
|
s.WriteToUDP([]byte(m.Spawn(value, kit.Dict(mdb.ZONE, "echo")).FormatMeta()), remote)
|
||||||
})
|
})
|
||||||
_broad_save(m, msg)
|
_broad_save(m, msg)
|
||||||
@ -98,7 +99,7 @@ func init() {
|
|||||||
OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
ctx.ProcessOpen(m, kit.Format("http://%s:%s", m.Option(tcp.HOST), m.Option(tcp.PORT)))
|
ctx.ProcessOpen(m, kit.Format("http://%s:%s", m.Option(tcp.HOST), m.Option(tcp.PORT)))
|
||||||
}},
|
}},
|
||||||
"send": {Hand: func(m *ice.Message, arg ...string) {
|
tcp.SEND: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
_broad_send(m, "", "", "255.255.255.255", "9020", arg...)
|
_broad_send(m, "", "", "255.255.255.255", "9020", arg...)
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, "host,port", mdb.FIELD, "time,hash,type,name,host,port", mdb.ACTION, OPEN), mdb.ClearHashOnExitAction())},
|
}, mdb.HashAction(mdb.SHORT, "host,port", mdb.FIELD, "time,hash,type,name,host,port", mdb.ACTION, OPEN), mdb.ClearHashOnExitAction())},
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
func _spide_create(m *ice.Message, name, address string) {
|
func _spide_create(m *ice.Message, name, address string) {
|
||||||
if uri, e := url.Parse(address); !m.Warn(e != nil || address == "", ice.ErrNotValid, address) {
|
if uri, e := url.Parse(address); !m.Warn(e != nil || address == "", ice.ErrNotValid, address) {
|
||||||
m.Logs(mdb.CREATE, SPIDE, name, ADDRESS, address)
|
m.Logs(mdb.INSERT, SPIDE, name, ADDRESS, address)
|
||||||
mdb.HashSelectUpdate(m, mdb.HashCreate(m, CLIENT_NAME, name), func(value ice.Map) {
|
mdb.HashSelectUpdate(m, mdb.HashCreate(m, CLIENT_NAME, name), func(value ice.Map) {
|
||||||
dir, file := path.Split(uri.EscapedPath())
|
dir, file := path.Split(uri.EscapedPath())
|
||||||
value[SPIDE_CLIENT] = kit.Dict(mdb.NAME, name, SPIDE_METHOD, http.MethodPost, "url", address, "origin", uri.Scheme+"://"+uri.Host,
|
value[SPIDE_CLIENT] = kit.Dict(mdb.NAME, name, SPIDE_METHOD, http.MethodPost, "url", address, "origin", uri.Scheme+"://"+uri.Host,
|
||||||
|
@ -71,6 +71,7 @@ func init() {
|
|||||||
if strings.Contains(file, ice.ICE) {
|
if strings.Contains(file, ice.ICE) {
|
||||||
m.Cmdy(PUBLISH, ice.CONTEXTS)
|
m.Cmdy(PUBLISH, ice.CONTEXTS)
|
||||||
}
|
}
|
||||||
|
m.StatusTime("version", strings.TrimPrefix(m.Cmdx(cli.SYSTEM, GO, "version"), "go version "))
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ func init() {
|
|||||||
defer web.ToastProcess(m)()
|
defer web.ToastProcess(m)()
|
||||||
files, adds, dels, last := _status_list(m)
|
files, adds, dels, last := _status_list(m)
|
||||||
m.StatusTimeCount("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
m.StatusTimeCount("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
||||||
m.Action(PULL, PUSH, TAGS, PIE, code.COMPILE, code.PUBLISH, "insteadof")
|
m.Action(PULL, PUSH, "insteadof")
|
||||||
m.Sort("repos,type,file")
|
m.Sort("repos,type,file")
|
||||||
} else {
|
} else {
|
||||||
_repos_cmd(m, arg[0], DIFF)
|
_repos_cmd(m, arg[0], DIFF)
|
||||||
|
@ -77,7 +77,7 @@ func init() {
|
|||||||
FIELDS, "id,tag,pane,tty,height,width,cmd",
|
FIELDS, "id,tag,pane,tty,height,width,cmd",
|
||||||
)},
|
)},
|
||||||
}, Commands: ice.Commands{
|
}, Commands: ice.Commands{
|
||||||
SESSION: {Name: "session session window pane cmd auto", Help: "会话管理", Actions: ice.MergeActions(ice.Actions{
|
SESSION: {Name: "session session window pane cmds auto", Help: "会话管理", Actions: ice.MergeActions(ice.Actions{
|
||||||
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { m.Cmd("", mdb.CREATE) }},
|
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { m.Cmd("", mdb.CREATE) }},
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(ctx.ACTION) == SCRIPT {
|
if m.Option(ctx.ACTION) == SCRIPT {
|
||||||
|
11
render.go
11
render.go
@ -37,12 +37,15 @@ func Render(m *Message, cmd string, args ...Any) string {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
for _, k := range kit.Split(k) {
|
for _, k := range kit.Split(k) {
|
||||||
list = append(list, kit.Format(`<input type="button" name="%s" value="%s">`, k,
|
list = append(list, kit.Format(`<input type="button" name="%s" value="%s">`,
|
||||||
kit.Select(k, kit.Value(m._cmd.Meta, kit.Keys("_trans", k)), m.Option(MSG_LANGUAGE) != "en")))
|
// k, kit.Select(k, kit.Value(m._cmd.Meta, kit.Keys("_trans", k)), m.Option(MSG_LANGUAGE) != "en")))
|
||||||
|
k, k))
|
||||||
}
|
}
|
||||||
case Map:
|
case Map:
|
||||||
for k, v := range k {
|
for k := range k {
|
||||||
list = append(list, kit.Format(`<input type="button" name="%s" value="%s">`, k, kit.Select(k, v, m.Option(MSG_LANGUAGE) != "en")))
|
list = append(list, kit.Format(`<input type="button" name="%s" value="%s">`,
|
||||||
|
k, k))
|
||||||
|
// k, kit.Select(k, v, m.Option(MSG_LANGUAGE) != "en")))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
list = append(list, Render(m, RENDER_BUTTON, kit.Format(k)))
|
list = append(list, Render(m, RENDER_BUTTON, kit.Format(k)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user