forked from x/ContextOS
opt cli.missyou
This commit is contained in:
parent
6e76f7377e
commit
6329a497ea
@ -578,6 +578,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
|
||||
m.Cmdp(time.Second, []string{"go init"}, []string{"cli.system", "go", "get",
|
||||
"cmd_env", "GOPATH", m.Conf("runtime", "boot.ctx_path")}, list)
|
||||
case "stat":
|
||||
m.Cmd("nfs.dir", "src", "dir_deep", "dir_type", "file").CopyTo(m, "append")
|
||||
m.Cmd("nfs.dir", "usr/librarys", "dir_deep", "dir_type", "file").CopyTo(m, "append")
|
||||
m.Set("result").Table()
|
||||
}
|
||||
return
|
||||
}},
|
||||
@ -745,8 +749,17 @@ var version = struct {
|
||||
"missyou": &ctx.Command{Name: "missyou", Help: "服务升级", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if len(arg) == 0 {
|
||||
m.Option("dir_root", "")
|
||||
m.Cmd("nfs.dir", m.Conf("missyou", "path")).Table(func() {
|
||||
m.Cmd("nfs.dir", m.Conf("missyou", "path")).Table(func(value map[string]string) {
|
||||
name := strings.TrimSuffix(value["filename"], "/")
|
||||
m.Add("append", "create_time", value["time"])
|
||||
m.Add("append", "you", name)
|
||||
if m.Confs("nfs.node", name) {
|
||||
m.Add("append", "status", "start")
|
||||
} else {
|
||||
m.Add("append", "status", "stop")
|
||||
}
|
||||
})
|
||||
m.Table()
|
||||
return
|
||||
}
|
||||
|
||||
@ -755,20 +768,29 @@ var version = struct {
|
||||
}
|
||||
|
||||
if m.Confs("ssh.node", arg[0]) {
|
||||
switch kit.Select("", arg, 1) {
|
||||
case "stop":
|
||||
m.Cmdy("ssh._route", arg[0], "context", "cli", "quit", 0)
|
||||
default:
|
||||
m.Echo(arg[0])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
p := path.Join(m.Conf("missyou", "path"), arg[0])
|
||||
if s, e := os.Stat(p); e == nil && s.IsDir() {
|
||||
m.Cmdy("cli.system", "node.sh", "create", p, "daemon", "cmd_daemon", "true")
|
||||
return e
|
||||
}
|
||||
|
||||
m.Cmdy("nfs.copy", path.Join(p, "etc/local.shy"), "usr/missyou/job.shy")
|
||||
if _, e := os.Stat(p); e != nil {
|
||||
m.Cmd("nfs.copy", path.Join(p, "etc/local.shy"), "usr/missyou/job.shy")
|
||||
m.Confm("missyou", "local", func(index string, local string) {
|
||||
m.Cmd("nfs.git", "clone", local, path.Join(p, "usr/local", index))
|
||||
})
|
||||
}
|
||||
|
||||
m.Cmdy("cli.system", m.Conf("runtime", "boot.ctx_bin"), "daemon",
|
||||
"cmd_dir", p,
|
||||
"cmd_env", "ctx_home", m.Conf("runtime", "boot.ctx_home"),
|
||||
"cmd_env", "ctx_box", fmt.Sprintf("http://localhost%s", m.Conf("runtime", "boot.web_port")),
|
||||
"cmd_daemon", "true",
|
||||
)
|
||||
return
|
||||
}},
|
||||
"quit": &ctx.Command{Name: "quit code", Help: "停止服务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
|
@ -4,5 +4,5 @@ var version = struct {
|
||||
host string
|
||||
self int
|
||||
}{
|
||||
"2019-06-30 12:52:58", "com", 26,
|
||||
"2019-06-30 17:36:39", "com.mac", 30,
|
||||
}
|
||||
|
@ -360,16 +360,14 @@ func (m *Message) CallBack(sync bool, cb func(msg *Message) (sub *Message), arg
|
||||
// m.Gos(m, func(m *Message) {
|
||||
m.Call(func(sub *Message) *Message {
|
||||
msg := cb(sub)
|
||||
m.Log("sync", m.Format("done", "result", "append"))
|
||||
wait <- m
|
||||
return msg
|
||||
}, arg...)
|
||||
// })
|
||||
|
||||
m.Log("sync", m.Format("wait", "result", "append"))
|
||||
select {
|
||||
case <-time.After(kit.Duration(m.Conf("call_timeout"))):
|
||||
m.Log("sync", m.Format("timeout", "result", "append"))
|
||||
m.Log("sync", m.Format("timeout", "detail", "option"))
|
||||
case <-wait:
|
||||
}
|
||||
return m
|
||||
|
@ -39,6 +39,7 @@ func (ctx *CTX) Begin(m *Message, arg ...string) Server {
|
||||
}
|
||||
func (ctx *CTX) Start(m *Message, arg ...string) bool {
|
||||
m.Cmd("ctx._init")
|
||||
kit.Log("fuck", "what")
|
||||
if m.Optionv("ps_target", Index); len(arg) == 0 {
|
||||
m.Option("cli.modal", "active")
|
||||
m.Option("log.disable", false)
|
||||
@ -46,10 +47,12 @@ func (ctx *CTX) Start(m *Message, arg ...string) bool {
|
||||
m.Cmd("log._init")
|
||||
m.Cmd("yac._init")
|
||||
m.Cmd("gdb._init")
|
||||
m.Log("fuck", "what")
|
||||
m.Cmd("cli.source", m.Conf("system", "script.init")).Cmd("cli.source", "stdio").Cmd("cli.source", m.Conf("system", "script.exit"))
|
||||
} else {
|
||||
m.Option("cli.modal", "action")
|
||||
m.Cmd("yac._init")
|
||||
m.Log("fuck", "what")
|
||||
for _, v := range m.Spawn().Cmd(arg).Meta["result"] {
|
||||
fmt.Printf("%s", v)
|
||||
}
|
||||
|
@ -368,7 +368,6 @@ func (m *Message) Table(cbs ...interface{}) *Message {
|
||||
|
||||
row[k], wor = data, append(wor, data+strings.Repeat(space, width[k]-kit.Width(data, len(space))))
|
||||
}
|
||||
m.Log("fuck", "waht %v", row)
|
||||
if !cb(row, wor, i) {
|
||||
break
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func (gdb *GDB) Start(m *ctx.Message, arg ...string) bool {
|
||||
action := m.Conf("signal", sig)
|
||||
m.Log("signal", "%v: %v", action, sig)
|
||||
switch action {
|
||||
case "QUIT":
|
||||
case "QUIT", "INT":
|
||||
m.Cmd("cli.quit", 0)
|
||||
case "restart":
|
||||
m.Cmd("cli.quit", 1)
|
||||
@ -143,7 +143,7 @@ var Index = &ctx.Context{Name: "gdb", Help: "调试中心",
|
||||
"31": "upgrade",
|
||||
|
||||
"1": "HUP",
|
||||
// "2": "INT",
|
||||
"2": "INT",
|
||||
// "9": "KILL",
|
||||
// "10": "BUS",
|
||||
// "11": "SEGV",
|
||||
|
@ -156,9 +156,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "missyou",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "action"},
|
||||
map[string]interface{}{"type": "button", "value": "行动"},
|
||||
map[string]interface{}{"type": "button", "value": "行动", "action": "auto"},
|
||||
},
|
||||
"exports": []interface{}{"you", "filename"},
|
||||
"exports": []interface{}{"you", "", "you"},
|
||||
},
|
||||
},
|
||||
"favor": []interface{}{
|
||||
@ -166,9 +166,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "public", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{"$$", "context", "aaa", "clip"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "you", "imports": "plugin_you"},
|
||||
map[string]interface{}{"type": "text", "name": "you", "imports": "plugin_you", "action": "auto"},
|
||||
map[string]interface{}{"type": "text", "name": "txt", "view": "long"},
|
||||
map[string]interface{}{"type": "button", "value": "运行"},
|
||||
map[string]interface{}{"type": "button", "value": "存储"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "qrcode", "componet_help": "生成二维码",
|
||||
@ -176,6 +176,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_type": "public", "componet_ctx": "web.chat", "componet_cmd": "login",
|
||||
"componet_args": []interface{}{"qrcode"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"label": "content", "type": "text", "name": "content"},
|
||||
map[string]interface{}{"type": "button", "value": "生成"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "salary", "componet_help": "计算工资",
|
||||
@ -212,17 +213,17 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{"$$", "context", "ssh", "remote"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
map[string]interface{}{"type": "button", "value": "执行", "action": "auto"},
|
||||
},
|
||||
"exports": []interface{}{"pod", "key", "pod"},
|
||||
"exports": []interface{}{"pod", "pod", "pod"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "ctx", "componet_help": "ctx",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{"$$", "context", "$$", "context"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod", "action": "auto"},
|
||||
map[string]interface{}{"type": "text", "name": "ctx", "value": "nfs", "imports": "plugin_ctx"},
|
||||
map[string]interface{}{"type": "button", "value": "模块"},
|
||||
map[string]interface{}{"type": "button", "value": "查看"},
|
||||
},
|
||||
"exports": []interface{}{"ctx", "names"},
|
||||
},
|
||||
@ -240,8 +241,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{"$$", "context", "nfs", "dir"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
|
||||
map[string]interface{}{"type": "text", "name": "dir", "value": "", "view": "long", "imports": []interface{}{"plugin_dir", "plugin_you"}},
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": []interface{}{"plugin_you", "plugin_pod"}},
|
||||
map[string]interface{}{"type": "text", "name": "dir", "value": "", "view": "long", "imports": []interface{}{"plugin_dir"}},
|
||||
map[string]interface{}{"type": "button", "value": "查看"},
|
||||
map[string]interface{}{"type": "button", "value": "回退", "click": "Back"},
|
||||
},
|
||||
@ -340,7 +341,12 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
}},
|
||||
"_node": &ctx.Command{Name: "_node [init|create name type module|delete name]", Help: "节点", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy("ctx.config", "node", "format", "table", "fields", "type", "module", "create_time")
|
||||
m.Confm("ssh.node", func(key string, value map[string]interface{}) {
|
||||
m.Add("append", "create_time", value["create_time"])
|
||||
m.Add("append", "pod", key)
|
||||
m.Add("append", "type", value["type"])
|
||||
})
|
||||
m.Sort("key").Table()
|
||||
return
|
||||
}
|
||||
|
||||
@ -672,6 +678,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
m.Confm("node", names[0], func(name string, node map[string]interface{}) {
|
||||
if kit.Format(node["type"]) != "master" {
|
||||
ps = append(ps, kit.Format(node["module"]))
|
||||
} else {
|
||||
ps = append(ps, "")
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -140,7 +140,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
||||
case "weixin":
|
||||
m.Cmdy(".js_token")
|
||||
case "qrcode":
|
||||
m.Append("qrcode", arg[1])
|
||||
m.Append("qrcode", kit.Select(m.Option("index_url"), arg, 1))
|
||||
case "rename":
|
||||
default:
|
||||
if m.Cmds("ssh.work", "share", arg[0]) {
|
||||
@ -211,6 +211,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
||||
"tool": map[string]interface{}{},
|
||||
})
|
||||
m.Echo(h)
|
||||
return
|
||||
|
||||
m.Option("username", m.Conf("runtime", "user.name"))
|
||||
m.Confm("flow", []string{h, "user"}, func(key string, value map[string]interface{}) {
|
||||
|
@ -320,7 +320,7 @@ page = Page({
|
||||
list.length > 0? list[0].Plugin.Runs(event, function() {
|
||||
field.Pane.Conf("running", true), setTimeout(function() {
|
||||
run(list.slice(1))
|
||||
}, 1000)
|
||||
}, 100)
|
||||
}): field.Pane.Conf("running", false)
|
||||
}
|
||||
run(list)
|
||||
|
@ -4,7 +4,7 @@ ctx = context = {
|
||||
for (var k in dataset) {
|
||||
option[k] = dataset[k].split(",")
|
||||
}
|
||||
kit.Log(option)
|
||||
kit.Log(cmd)
|
||||
this.GET("", option, function(msg) {
|
||||
msg[0] && (msg = msg[0])
|
||||
// msg && (msg.__proto__ = (page || {}))
|
||||
|
@ -23,7 +23,7 @@ fieldset>form.option div.hide {
|
||||
display:none;
|
||||
}
|
||||
fieldset>form.option div input.args {
|
||||
width:80px;
|
||||
width:100px;
|
||||
}
|
||||
fieldset>form.option div.cmd input.args {
|
||||
color:white;
|
||||
@ -81,7 +81,8 @@ fieldset>div.output table td {
|
||||
}
|
||||
|
||||
fieldset.toast {
|
||||
background-color:#ffffff00;
|
||||
border:solid 2px red;
|
||||
background-color:#ffffff;
|
||||
position:absolute;
|
||||
display:none;
|
||||
}
|
||||
|
@ -110,6 +110,10 @@ function Page(page) {
|
||||
var toast = kit.ModifyView("fieldset.toast", {
|
||||
display: "block", dialog: [args.width||200, args.height||40], padding: 10,
|
||||
})
|
||||
if (!text) {
|
||||
toast.style.display = "none"
|
||||
return
|
||||
}
|
||||
|
||||
var list = [{text: [args.text||""]}]
|
||||
args.inputs && args.inputs.forEach(function(input) {
|
||||
@ -144,6 +148,7 @@ function Page(page) {
|
||||
var ui = kit.AppendChild(kit.ModifyNode(toast.querySelector("div.output"), ""), list)
|
||||
args.duration !=- 1 && setTimeout(function(){toast.style.display = "none"}, args.duration||3000)
|
||||
page.toast = toast
|
||||
return true
|
||||
},
|
||||
ondebug: function() {
|
||||
if (!this.debug) {
|
||||
@ -624,8 +629,11 @@ function Plugin(page, pane, field) {
|
||||
};
|
||||
|
||||
(typeof item.imports == "object"? item.imports: typeof item.imports == "string"? [item.imports]: []).forEach(function(imports) {
|
||||
page.Sync(imports).change(action.Goto)
|
||||
page.Sync(imports).change(function(value) {
|
||||
(action.value = value) && item.action == "auto" && plugin.Runs(window.event)
|
||||
})
|
||||
})
|
||||
item.type == "button" && item.action == "auto" && plugin.Runs(window.event)
|
||||
return action
|
||||
},
|
||||
Remove: function() {
|
||||
@ -669,6 +677,14 @@ function Plugin(page, pane, field) {
|
||||
plugin.ondaemon[display.deal||"table"](msg)
|
||||
})
|
||||
},
|
||||
Delay: function(time, event, text) {
|
||||
page.ontoast(text, "run", -1)
|
||||
setTimeout(function() {
|
||||
plugin.Runs(event)
|
||||
page.ontoast("")
|
||||
}, time)
|
||||
return time
|
||||
},
|
||||
Clear: function() {
|
||||
output.innerHTML = ""
|
||||
},
|
||||
@ -684,7 +700,7 @@ function Plugin(page, pane, field) {
|
||||
if (line["latitude"]) {
|
||||
page.openLocation(line.latitude, line.longitude, line.location)
|
||||
}
|
||||
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name))
|
||||
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
||||
});
|
||||
(display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}])
|
||||
},
|
||||
@ -693,13 +709,22 @@ function Plugin(page, pane, field) {
|
||||
"": function(value, name) {
|
||||
return value
|
||||
},
|
||||
"pod": function(value, name) {
|
||||
you: function(value, name, line) {
|
||||
window.event.Plugin = plugin
|
||||
name == "status" && (line.status == "start"? function() {
|
||||
plugin.Delay(2000, window.event, line.you+" stop...") && field.Run(window.event, [line.you, "stop"])
|
||||
}(): field.Run(window.event, [line.you], function(msg) {
|
||||
plugin.Delay(1000, window.event, line.you+" start...") && plugin.Runs(window.event)
|
||||
}))
|
||||
return name == "you"? value: undefined
|
||||
},
|
||||
pod: function(value, name) {
|
||||
if (option[exports[0]].value) {
|
||||
return option[exports[0]].value+"."+value
|
||||
}
|
||||
return value
|
||||
},
|
||||
"dir": function(value, name) {
|
||||
dir: function(value, name) {
|
||||
if (value.endsWith("/")) {
|
||||
return option[exports[0]] + value
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user