forked from x/ContextOS
opt some
This commit is contained in:
parent
d868dacd3a
commit
4c3223f63f
@ -121,10 +121,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
}, Help: "源码编译"},
|
||||
"publish": &ctx.Config{Name: "publish", Value: map[string]interface{}{
|
||||
"path": "usr/publish", "list": map[string]interface{}{
|
||||
"boot_sh": "bin/boot.sh",
|
||||
"zone_sh": "bin/zone.sh",
|
||||
"user_sh": "bin/user.sh",
|
||||
"node_sh": "bin/node.sh",
|
||||
"boot_sh": "bin/boot.sh",
|
||||
"zone_sh": "bin/zone.sh",
|
||||
"user_sh": "bin/user.sh",
|
||||
"node_sh": "bin/node.sh",
|
||||
|
||||
"init_shy": "etc/init.shy",
|
||||
"common_shy": "etc/common.shy",
|
||||
@ -145,10 +145,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
"list": map[string]interface{}{
|
||||
"bench": "bin/bench.new",
|
||||
|
||||
"boot_sh": "bin/boot.sh",
|
||||
"zone_sh": "bin/zone.sh",
|
||||
"user_sh": "bin/user.sh",
|
||||
"node_sh": "bin/node.sh",
|
||||
"boot_sh": "bin/boot.sh",
|
||||
"zone_sh": "bin/zone.sh",
|
||||
"user_sh": "bin/user.sh",
|
||||
"node_sh": "bin/node.sh",
|
||||
|
||||
"init_shy": "etc/init.shy",
|
||||
"common_shy": "etc/common.shy",
|
||||
@ -248,7 +248,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
"cmd_temp": -1,
|
||||
"cmd_parse": 2,
|
||||
"cmd_error": 0,
|
||||
"cmd_select": -1,
|
||||
"cmd_select": -1,
|
||||
"app_log": 1,
|
||||
}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
// 管道参数
|
||||
@ -624,9 +624,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
format := kit.Select(m.Conf("time", "format"), m.Option("time_format"))
|
||||
t, stamp := time.Now(), true
|
||||
if len(arg) > 0 {
|
||||
if arg[0] == "show" {
|
||||
stamp = false
|
||||
} else if i, e := strconv.ParseInt(arg[0], 10, 64); e == nil {
|
||||
if i, e := strconv.ParseInt(arg[0], 10, 64); e == nil {
|
||||
t, stamp, arg = time.Unix(int64(i/int64(m.Confi("time", "unit"))), 0), false, arg[1:]
|
||||
} else if n, e := time.ParseInLocation(format, arg[0], time.Local); e == nil {
|
||||
t, arg = n, arg[1:]
|
||||
@ -708,8 +706,8 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
return
|
||||
}},
|
||||
"proc": &ctx.Command{Name: "proc", Help: "进程管理", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Cmdy("cli.system", "ps", kit.Select("ax", arg, 0), "cmd_parse", "cut")
|
||||
if len(arg) > 1 {
|
||||
m.Cmdy("cli.system", "cmd_parse", "cut", "ps", kit.Select("ax", arg, 0))
|
||||
if len(arg) > 0 {
|
||||
m.Cmd("select", "reg", "COMMAND", arg[1])
|
||||
}
|
||||
return
|
||||
@ -758,13 +756,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
[]string{"stash"}, []string{"pull"}, []string{"stash", "pop"},
|
||||
})
|
||||
|
||||
// 更新依赖
|
||||
list := [][]string{}
|
||||
m.Confm("compile", "dep", func(index int, value string) {
|
||||
list = append(list, []string{value})
|
||||
})
|
||||
m.Cmdp(0, []string{"go build"}, []string{"cli.system", "go", "get"}, list)
|
||||
|
||||
// 代码状态
|
||||
m.Cmdy("cli.system", "git", "status", "-sb", "cmd_parse", "cut")
|
||||
return e
|
||||
@ -776,13 +767,16 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
[]string{"stash"}, []string{"pull"}, []string{"checkout", "-f", "master"}, []string{"stash", "pop"},
|
||||
})
|
||||
|
||||
// 下载依赖
|
||||
list := [][]string{}
|
||||
m.Confm("compile", "dep", func(index int, value string) {
|
||||
list = append(list, []string{value})
|
||||
})
|
||||
m.Cmdp(0, []string{"go build"}, []string{"cli.system", "go", "get"}, list)
|
||||
|
||||
case "stat":
|
||||
// 代码统计
|
||||
m.Cmdy("nfs.dir", kit.Select("src", arg, 1), "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r")
|
||||
|
||||
case "stats":
|
||||
// 代码统计
|
||||
m.Cmdy("nfs.dir", kit.Select("src", arg, 1), "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r", "dir_select", "group", "")
|
||||
m.Cmdy("nfs.dir", "src", "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r")
|
||||
|
||||
case "trend":
|
||||
// 提交记录
|
||||
@ -875,7 +869,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
env := []string{
|
||||
"cmd_env", "GOOS", goos, "cmd_env", "GOARCH", arch,
|
||||
"cmd_env", "GOTMPDIR", tmp, "cmd_env", "GOCACHE", tmp,
|
||||
"cmd_env", "GOPATH", m.Conf("runtime", "boot.ctx_home") + ":" + os.Getenv("GOPATH"),
|
||||
"cmd_env", "GOPATH", m.Conf("runtime", "boot.ctx_home")+":"+os.Getenv("GOPATH"),
|
||||
"cmd_env", "PATH", os.Getenv("PATH"),
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,5 @@ var version = struct {
|
||||
host string
|
||||
self int
|
||||
}{
|
||||
"2019-08-31 02:08:47", "mac", 497,
|
||||
"2019-09-02 20:11:08", "centos", 489,
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ var Index = &ctx.Context{Name: "log", Help: "日志中心",
|
||||
"meta": map[string]interface{}{
|
||||
"short": []interface{}{"time", "ship"},
|
||||
"long": []interface{}{"time", "ship"},
|
||||
"cost": []interface{}{"time", "ship", "cost"},
|
||||
},
|
||||
|
||||
"debug": map[string]interface{}{"value": []interface{}{"debug"}},
|
||||
@ -150,13 +151,14 @@ var Index = &ctx.Context{Name: "log", Help: "日志中心",
|
||||
"close": map[string]interface{}{"value": []interface{}{"bench", "red"}},
|
||||
"stack": map[string]interface{}{"value": []interface{}{"bench", "yellow"}},
|
||||
"warn": map[string]interface{}{"value": []interface{}{"bench", "yellow"}},
|
||||
"time": map[string]interface{}{"value": []interface{}{"bench", "red"}},
|
||||
|
||||
"right": map[string]interface{}{"value": []interface{}{"right"}},
|
||||
|
||||
"error": map[string]interface{}{"value": []interface{}{"error", "red"}},
|
||||
"trace": map[string]interface{}{"value": []interface{}{"error", "red"}},
|
||||
|
||||
"cmd": map[string]interface{}{"value": []interface{}{"bench", "green"},
|
||||
"cmd": map[string]interface{}{"value": []interface{}{"bench", "green", "cost"},
|
||||
"lex": map[string]interface{}{"value": []interface{}{"debug", "green"}},
|
||||
"yac": map[string]interface{}{"value": []interface{}{"debug", "green"}},
|
||||
"cli": map[string]interface{}{
|
||||
|
@ -360,6 +360,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
args = append(args, msg.Parse(v))
|
||||
}
|
||||
}
|
||||
m.Log("time", "check: %v", m.Format("cost"))
|
||||
msg.Cmd(tool["componet_cmd"], args, arg).CopyTo(m)
|
||||
|
||||
default:
|
||||
@ -633,7 +634,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
return
|
||||
}},
|
||||
"_route": {Name: "_route", Help: "路由", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Log("time", "exec: %v", m.Format("cost"))
|
||||
if len(arg) == 0 {
|
||||
return
|
||||
}
|
||||
@ -662,6 +662,10 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
if rest := kit.Select("", names, 1); names[0] != "" {
|
||||
// 数字签名
|
||||
if !m.Options("remote_code") && arg[0] != "_check" {
|
||||
for _, k := range []string{"river"}{
|
||||
m.Option(k, m.Option(k))
|
||||
}
|
||||
|
||||
hash, meta := kit.Hash("rand",
|
||||
m.Option("text.time", m.Time("stamp")),
|
||||
m.Option("text.cmd", strings.Join(arg, " ")),
|
||||
@ -715,7 +719,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
|
||||
defer func() { m.Back(m) }()
|
||||
|
||||
m.Log("time", "exec: %v", m.Format("cost"))
|
||||
if !m.Options("remote_code") {
|
||||
// 本地调用
|
||||
m.Cmdy(arg)
|
||||
@ -749,8 +752,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
m.Echo("node error of %s", m.Option("node.route"))
|
||||
|
||||
} else {
|
||||
m.Log("time", "exec: %v", m.Format("cost"))
|
||||
// 执行命令
|
||||
m.Log("time", "check: %v", m.Format("cost"))
|
||||
m.Cmd("_exec", arg)
|
||||
m.Log("time", "exec: %v", m.Format("cost"))
|
||||
}
|
||||
@ -1105,8 +1108,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
}
|
||||
|
||||
// 执行命令
|
||||
m.Log("time", "right: %v", m.Format("cost"))
|
||||
m.Cmdy(arg)
|
||||
m.Log("time", "exec: %v", m.Format("cost"))
|
||||
return
|
||||
}},
|
||||
|
||||
|
@ -186,6 +186,7 @@ func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) {
|
||||
}
|
||||
|
||||
// 用户登录
|
||||
msg.Log("time", "parse: %v", msg.Format("cost"))
|
||||
if msg.Put("option", "request", r).Put("option", "response", w).Sess("web", msg); web.Login(msg, w, r) {
|
||||
msg.Log("cmd", "%s [] %v", key, msg.Meta["option"])
|
||||
cmd.Hand(msg, msg.Target(), msg.Option("path"))
|
||||
@ -875,6 +876,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
continue
|
||||
}
|
||||
// 执行命令
|
||||
m.Log("time", "check: %v", m.Format("cost"))
|
||||
msg.Cmd(arg)
|
||||
}
|
||||
}
|
||||
|
@ -1086,6 +1086,7 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
||||
self := &ctx.Command{Name: strings.Join(arg[1:], " "), Help: []string{"pwd", "ls"}}
|
||||
self.Hand = func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Goshy(self.Help.([]string), 0, nil, nil)
|
||||
m.Log("time", "parse: %v", m.Format("cost"))
|
||||
return
|
||||
}
|
||||
m.Target().Commands[arg[1]] = self
|
||||
|
@ -14,8 +14,8 @@ import (
|
||||
var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||
Caches: map[string]*ctx.Cache{},
|
||||
Configs: map[string]*ctx.Config{
|
||||
"login": &ctx.Config{Name: "login", Value: map[string]interface{}{"check": "false"}, Help: "用户登录"},
|
||||
"componet": &ctx.Config{Name: "componet", Value: map[string]interface{}{
|
||||
"login": {Name: "login", Value: map[string]interface{}{"check": "false"}, Help: "用户登录"},
|
||||
"componet": {Name: "componet", Value: map[string]interface{}{
|
||||
"index": []interface{}{
|
||||
map[string]interface{}{"name": "wiki",
|
||||
"tmpl": "head", "metas": []interface{}{map[string]interface{}{
|
||||
@ -45,17 +45,17 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
|
||||
},
|
||||
}, Help: "组件列表"},
|
||||
|
||||
"level": &ctx.Config{Name: "level", Value: "local/wiki/自然/编程", Help: "路由数量"},
|
||||
"class": &ctx.Config{Name: "class", Value: "", Help: "路由数量"},
|
||||
"favor": &ctx.Config{Name: "favor", Value: "index.md", Help: "路由数量"},
|
||||
"level": {Name: "level", Value: "local/wiki/自然/编程", Help: "路由数量"},
|
||||
"class": {Name: "class", Value: "", Help: "路由数量"},
|
||||
"favor": {Name: "favor", Value: "index.md", Help: "路由数量"},
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"tree": &ctx.Command{Name: "tree", Help: "目录", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
"tree": {Name: "tree", Help: "目录", Form: map[string]int{"level": 1, "class": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Cmdy("nfs.dir", path.Join(m.Confx("level"), m.Confx("class", arg, 0)),
|
||||
"time", "size", "line", "file", "dir_sort", "time", "time_r")
|
||||
return
|
||||
}},
|
||||
"text": &ctx.Command{Name: "text", Help: "文章", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
"text": {Name: "text", Help: "文章", Form: map[string]int{"level": 1, "class": 1, "favor": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
which := m.Cmdx("nfs.path", path.Join(m.Confx("level"), m.Confx("class", arg, 1), m.Confx("favor", arg, 0)))
|
||||
|
||||
buffer := bytes.NewBuffer([]byte{})
|
||||
|
@ -42,9 +42,9 @@ fun note "记事本" public \
|
||||
feature display inner
|
||||
|
||||
if $2 == "" || $2 ~ ".*/$"
|
||||
copy ssh._route _ context wiki tree __
|
||||
copy ssh._route _ context wiki tree __ level local/wiki
|
||||
else
|
||||
copy ssh._route _ context wiki text __
|
||||
copy ssh._route _ context wiki text __ level local/wiki
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user