forked from x/ContextOS
opt cli.runtime
Change-Id: I5c8c1de4b9db7e367add756eade23d9530c0a98a
This commit is contained in:
parent
2b95d3b7a5
commit
f0faba149d
@ -42,12 +42,12 @@ bind i display-panes
|
||||
bind x confirm-before -p "kill-pane #P? (y/n)" kill-pane
|
||||
|
||||
bind b break-pane
|
||||
bind u split-window
|
||||
bind v split-window -h
|
||||
# bind u split-window
|
||||
# bind v split-window -h
|
||||
bind u split-window -c "#{pane_current_path}"
|
||||
bind v split-window -h -c "#{pane_current_path}"
|
||||
bind C-u split-window -f
|
||||
bind C-v split-window -f -h
|
||||
# bind u split-window -c "#{pane_current_path}"
|
||||
# bind v split-window -h -c "#{pane_current_path}"
|
||||
# bind C-u split-window -f -c "#{pane_current_path}"
|
||||
# bind C-v split-window -f -h -c "#{pane_current_path}"
|
||||
|
||||
|
@ -4,6 +4,8 @@ syntax match shyCommand "\(^\|\t\| \|$(\)[a-zA-Z0-9_\.]\+\>"
|
||||
syntax match shyConfig "\(^\|\t\| \|$(\)config\>"
|
||||
syntax match shyCache "\(^\|\t\| \|$(\)cache\>"
|
||||
|
||||
syntax match shyStmt "return"
|
||||
|
||||
syntax match shyString "'[^']*'"
|
||||
syntax match shyString "\"[^\"]*\""
|
||||
syntax match shyNumber "-\=\<\d\+\>#\="
|
||||
@ -27,6 +29,8 @@ highlight shyCommand ctermfg=green
|
||||
highlight shyConfig ctermfg=yellow
|
||||
highlight shyCache ctermfg=yellow
|
||||
|
||||
highlight shyStmt ctermfg=yellow
|
||||
|
||||
highlight shyString ctermfg=magenta
|
||||
highlight shyNumber ctermfg=magenta
|
||||
highlight shyVariable ctermfg=magenta
|
||||
|
@ -100,9 +100,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
Configs: map[string]*ctx.Config{
|
||||
"runtime": &ctx.Config{Name: "runtime", Value: map[string]interface{}{
|
||||
"init_env": []interface{}{"ctx_dev", "ctx_box", "ctx_root", "ctx_home", "USER"},
|
||||
"script": map[string]interface{}{"sh": "bash", "shy": "source", "py": "python"},
|
||||
"init_shy": "etc/init.shy", "exit_shy": "etc/exit.shy",
|
||||
"web_port": ":9094", "ssh_port": ":9090", "ssh_ports": []interface{}{},
|
||||
"boot": map[string]interface{}{"web_port": ":9094", "ssh_port": ":9090"},
|
||||
"script": map[string]interface{}{
|
||||
"sh": "bash", "shy": "source", "py": "python",
|
||||
"init": "etc/init.shy", "exit": "etc/exit.shy",
|
||||
},
|
||||
}, Help: "运行环境"},
|
||||
|
||||
"alias": &ctx.Config{Name: "alias", Value: map[string]interface{}{
|
||||
@ -136,19 +138,19 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"init": &ctx.Command{Name: "init", Help: "停止服务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Conf("runtime", "GOARCH", runtime.GOARCH)
|
||||
m.Conf("runtime", "GOOS", runtime.GOOS)
|
||||
m.Conf("runtime", "pid", os.Getpid())
|
||||
m.Conf("runtime", "host.GOARCH", runtime.GOARCH)
|
||||
m.Conf("runtime", "host.GOOS", runtime.GOOS)
|
||||
m.Conf("runtime", "host.pid", os.Getpid())
|
||||
|
||||
if name, e := os.Hostname(); e == nil {
|
||||
m.Conf("runtime", "hostname", name)
|
||||
m.Conf("runtime", "boot.hostname", name)
|
||||
}
|
||||
if name, e := os.Getwd(); e == nil {
|
||||
_, file := path.Split(name)
|
||||
m.Conf("runtime", "pathname", file)
|
||||
m.Conf("runtime", "boot.pathname", file)
|
||||
}
|
||||
m.Confm("runtime", "init_env", func(index int, key string) {
|
||||
m.Conf("runtime", key, os.Getenv(key))
|
||||
m.Conf("runtime", "boot."+key, os.Getenv(key))
|
||||
})
|
||||
return
|
||||
}},
|
||||
@ -313,7 +315,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
return
|
||||
}},
|
||||
"exit": &ctx.Command{Name: "exit code", Help: "停止服务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Cmd("cli.source", m.Conf("exit_shy"))
|
||||
m.Cmd("cli.source", m.Conf("runtime", "script.exit"))
|
||||
go func() {
|
||||
time.Sleep(time.Second * 3)
|
||||
os.Exit(kit.Int(arg[0]))
|
||||
|
@ -41,7 +41,7 @@ func (ctx *CTX) Start(m *Message, arg ...string) bool {
|
||||
m.Cmd("ctx.init")
|
||||
if m.Optionv("ps_target", Index); len(arg) == 0 {
|
||||
m.Cap("stream", "shy")
|
||||
m.Cmd("cli.source", m.Conf("runtime", "init_shy")).Cmd("cli.source", "stdio").Cmd("cli.source", m.Conf("runtime", "exit_shy"))
|
||||
m.Cmd("cli.source", m.Conf("runtime", "script.init")).Cmd("cli.source", "stdio").Cmd("cli.source", m.Conf("runtime", "script.exit"))
|
||||
} else {
|
||||
m.Cmd("cli.source", arg)
|
||||
}
|
||||
|
@ -917,7 +917,7 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool {
|
||||
msg := m.Backs(m.Spawn(m.Source()).Set(
|
||||
"detail", line).Set(
|
||||
"option", "file_pos", i).Set(
|
||||
"option", "username", m.Conf("runtime", "USER")))
|
||||
"option", "username", m.Conf("runtime", "boot.USER")))
|
||||
|
||||
nfs.printf(m.Conf("prompt"), line)
|
||||
nfs.printf(msg.Meta["result"])
|
||||
@ -1132,8 +1132,8 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"init": &ctx.Command{Name: "init", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Conf("paths", -2, m.Conf("runtime", "ctx_home"))
|
||||
m.Conf("paths", -2, m.Conf("runtime", "ctx_root"))
|
||||
m.Conf("paths", -2, m.Conf("runtime", "boot.ctx_home"))
|
||||
m.Conf("paths", -2, m.Conf("runtime", "boot.ctx_root"))
|
||||
return
|
||||
}},
|
||||
"pwd": &ctx.Command{Name: "pwd [all] | [[index] path] ", Help: "工作目录,all: 查看所有, index path: 设置路径, path: 设置当前路径", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
|
@ -44,15 +44,15 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"init": &ctx.Command{Name: "init", Help: "启动", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if m.Confs("runtime", "ctx_box") {
|
||||
if m.Confs("runtime", "boot.ctx_box") {
|
||||
m.Conf("runtime", "node.type", "worker")
|
||||
m.Conf("runtime", "node.name", m.Conf("runtime", "pathname"))
|
||||
m.Conf("runtime", "node.name", m.Conf("runtime", "boot.pathname"))
|
||||
} else {
|
||||
m.Conf("runtime", "node.type", "server")
|
||||
m.Conf("runtime", "node.name", strings.Replace(strings.TrimSuffix(m.Conf("runtime", "hostname"), ".local"), ".", "_", -1))
|
||||
m.Conf("runtime", "node.name", strings.Replace(strings.TrimSuffix(m.Conf("runtime", "boot.hostname"), ".local"), ".", "_", -1))
|
||||
}
|
||||
m.Conf("runtime", "node.route", m.Conf("runtime", "node.name"))
|
||||
m.Conf("runtime", "user.name", m.Conf("runtime", "USER"))
|
||||
m.Conf("runtime", "user.name", m.Conf("runtime", "boot.USER"))
|
||||
return
|
||||
}},
|
||||
"remote": &ctx.Command{Name: "remote auto|dial|listen args...", Help: "远程连接", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
@ -70,9 +70,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
|
||||
switch arg[0] {
|
||||
case "auto": // 自动连接
|
||||
if m.Cmd("ssh.remote", "dial", "consul", "/shadow"); !m.Confs("runtime", "ctx_box") {
|
||||
m.Cmd("ssh.remote", "listen", m.Conf("runtime", "ssh_port"))
|
||||
m.Cmd("web.serve", "usr", m.Conf("runtime", "web_port"))
|
||||
if m.Cmd("ssh.remote", "dial", "consul", "/shadow"); !m.Confs("runtime", "boot.ctx_box") {
|
||||
m.Cmd("ssh.remote", "listen", m.Conf("runtime", "boot.ssh_port"))
|
||||
m.Cmd("web.serve", "usr", m.Conf("runtime", "boot.web_port"))
|
||||
}
|
||||
|
||||
case "listen": // 监听连接
|
||||
|
@ -144,8 +144,8 @@ func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) {
|
||||
msg.Option("path", r.URL.Path)
|
||||
msg.Optionv("debug", false)
|
||||
|
||||
msg.Option("GOOS", m.Conf("runtime", "GOOS"))
|
||||
msg.Option("GOOS", m.Conf("runtime", "GOARCH"))
|
||||
msg.Option("GOOS", m.Conf("runtime", "host.GOOS"))
|
||||
msg.Option("GOOS", m.Conf("runtime", "host.GOARCH"))
|
||||
agent := r.Header.Get("User-Agent")
|
||||
switch {
|
||||
case strings.Contains(agent, "Macintosh"):
|
||||
@ -398,7 +398,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"init": &ctx.Command{Name: "init", Help: "post请求", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
m.Cmd("web.spide", "dev", "client", "new", kit.Select(m.Conf("runtime", "ctx_dev"), m.Conf("runtime", "ctx_box")))
|
||||
m.Cmd("web.spide", "dev", "client", "new", kit.Select(m.Conf("runtime", "boot.ctx_dev"), m.Conf("runtime", "boot.ctx_box")))
|
||||
return
|
||||
}},
|
||||
"spide": &ctx.Command{Name: "spide [which [client|cookie [name [value]]]]", Help: "爬虫配置", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
|
@ -278,7 +278,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||
m.Assert(e)
|
||||
}
|
||||
if m.Cmd("web.get", "dev", fmt.Sprintf("code/upgrade/%s", link),
|
||||
"GOOS", m.Conf("runtime", "GOOS"), "GOARCH", m.Conf("runtime", "GOARCH"),
|
||||
"GOOS", m.Conf("runtime", "host.GOOS"), "GOARCH", m.Conf("runtime", "host.GOARCH"),
|
||||
"save", file); strings.HasPrefix(file, "bin/") {
|
||||
if m.Cmd("cli.system", "chmod", "u+x", file); link == "bench" {
|
||||
m.Cmd("cli.system", "mv", "bin/bench", fmt.Sprintf("bin/bench_%s", m.Time("20060102_150405")))
|
||||
|
Loading…
x
Reference in New Issue
Block a user