1
0
forked from x/ContextOS

fix multi thread

This commit is contained in:
shylinux 2019-04-30 00:33:36 +08:00
parent ed027c8c9d
commit c55c64ae21
4 changed files with 11 additions and 7 deletions

View File

@ -30,9 +30,9 @@ install() {
wget -O etc/exit.shy $ctx_dev/exit_shy
wget -O etc/init.shy $ctx_dev/init_shy
wget -O etc/common.shy $ctx_dev/common_shy
wget -O bin/bench.new "$ctx_dev/bench?GOOS=$GOOS&GOARCH=$GOARCH" && chmod u+x bin/bench.new && mv bin/bench.new bin/bench
wget -O bin/boot.sh $ctx_dev/boot_sh && chmod u+x bin/boot.sh
wget -O bin/node.sh $ctx_dev/node_sh && chmod u+x bin/node.sh
wget -O bin/bench.new "$ctx_dev/bench?GOOS=$GOOS&GOARCH=$GOARCH" && chmod a+x bin/bench.new && mv bin/bench.new bin/bench
wget -O bin/boot.sh $ctx_dev/boot_sh && chmod a+x bin/boot.sh
wget -O bin/node.sh $ctx_dev/node_sh && chmod a+x bin/node.sh
}
state() {

View File

@ -148,6 +148,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
"runtime": &ctx.Command{Name: "runtime", Help: "runtime", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
mem := &runtime.MemStats{}
runtime.ReadMemStats(mem)
m.Append("NumCPU", runtime.NumCPU())
m.Append("NumGo", runtime.NumGoroutine())
m.Append("NumGC", mem.NumGC)
m.Append("other", kit.FmtSize(mem.OtherSys))
@ -653,6 +654,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
m.Conf("runtime", "host.GOARCH", runtime.GOARCH)
m.Conf("runtime", "host.GOOS", runtime.GOOS)
m.Conf("runtime", "host.pid", os.Getpid())
runtime.GOMAXPROCS(1)
if name, e := os.Hostname(); e == nil {
m.Conf("runtime", "boot.hostname", kit.Select(name, os.Getenv("HOSTNAME")))

View File

@ -214,9 +214,11 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
if names[0] == "%" || names[0] == "*" { // 广播命令
m.Confm("node", names[0], func(name string, node map[string]interface{}) {
m.Find(kit.Format(node["module"]), true).Copy(m, "option").CallBack(sync, func(sub *ctx.Message) *ctx.Message {
return m.CopyFuck(sub, "append").CopyFuck(sub, "result").Echo("\n\n")
}, "send", rest, arg)
if kit.Format(node["type"]) != "master" {
m.Find(kit.Format(node["module"]), true).Copy(m, "option").CallBack(sync, func(sub *ctx.Message) *ctx.Message {
return m.CopyFuck(sub, "append").CopyFuck(sub, "result").Echo("\n\n")
}, "send", rest, arg)
}
})
} else if m.Confm("node", names[0], func(node map[string]interface{}) { // 单播命令

View File

@ -513,7 +513,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
if m.Cmd("web.get", "dev", fmt.Sprintf("code/upgrade/%s", link),
"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" {
if m.Cmd("cli.system", "chmod", "a+x", file); link == "bench" {
m.Cmd("cli.system", "mv", "bin/bench", fmt.Sprintf("bin/bench_%s", m.Time("20060102_150405")))
m.Cmd("cli.system", "mv", "bin/bench.new", "bin/bench")
}