1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 08:48:06 +08:00
This commit is contained in:
shylinux 2019-02-02 11:54:54 +08:00
parent 1edf3227b9
commit 07b6af2772
4 changed files with 37 additions and 33 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
var/
pkg/
*.swp
*.swo
# Binaries for programs and plugins
*.exe
*.dll

View File

@ -1,5 +1,6 @@
BENCH=src/examples/app/bench.go
upgrade=usr/upgrade/
install:
@go get github.com/nsf/termbox-go
@ -50,17 +51,17 @@ tar_all: tar linux64 darwin win64
tar zcvf tar.tgz tar
linux_arm:
GOARCH=arm GOOS=linux go build -o bench.linux.arm $(BENCH)
GOARCH=arm GOOS=linux go build -o $(upgrade)bench.linux.arm $(BENCH)
linux32:
GOARCH=386 GOOS=linux go build -o bench.linux32 $(BENCH)
GOARCH=386 GOOS=linux go build -o $(upgrade)bench.linux32 $(BENCH)
linux64:
GOARCH=amd64 GOOS=linux go build -o bench.linux64 $(BENCH)
GOARCH=amd64 GOOS=linux go build -o $(upgrade)bench.linux64 $(BENCH)
darwin:
GOARCH=amd64 GOOS=darwin go build -o bench.darwin $(BENCH)
GOARCH=amd64 GOOS=darwin go build -o $(upgrade)bench.darwin $(BENCH)
win32:
GOARCH=386 GOOS=windows go build -o bench.win32.exe $(BENCH)
GOARCH=386 GOOS=windows go build -o $(upgrade)bench.win32.exe $(BENCH)
win64:
GOARCH=amd64 GOOS=windows go build -o bench.win64.exe $(BENCH)
GOARCH=amd64 GOOS=windows go build -o $(upgrade)bench.win64.exe $(BENCH)
DOTS=etc/dotsfile

View File

@ -1,23 +1,3 @@
source common.shy
source local.shy
~ssh
remote listen :9090 right sub
~aaa
role void componet source js_token
role tech componet mp command share
role tech componet chat command share
role tech componet chat command nfs.pwd ls
role tech componet index command source
role tech componet index command context
role tech componet remote command nfs.pwd ls
role tech componet source command nfs.pwd ls
user root shy shy
user tech sub sub
~web
config spide "" client "localhost:9094"
serve

View File

@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"path"
"strconv"
"strings"
)
@ -214,12 +215,18 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
},
}, Help: "组件列表"},
"upgrade": &ctx.Config{Name: "upgrade", Value: map[string]interface{}{
"system": []interface{}{"exit_shy", "common_shy", "init_shy", "bench", "boot.sh"},
"portal": []interface{}{"code_tmpl", "code_js", "context_js"},
"file": map[string]interface{}{
"boot_sh": "bin/boot.sh",
"bench": "bin/bench.new",
"init_shy": "etc/init.shy",
"common_shy": "etc/common.shy",
"exit_shy": "etc/exit.shy",
"code_tmpl": "usr/template/code/code.tmpl",
"code_js": "usr/librarys/code.js",
"context_js": "usr/librarys/context.js",
},
}, Help: "日志地址"},
},
@ -235,28 +242,43 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
p = bench
}
}
m.Log("fuck", "wha t%v", p)
if _, e = os.Stat(p); e != nil {
list := strings.Split(key, "/")
m.Log("fuck", "wha t%v", list)
p = m.Cmdx("nfs.path", m.Conf("upgrade", []string{"file", list[len(list)-1]}))
}
m.Log("fuck", "wha t%v", e)
m.Log("info", "upgrade %s %s", p, m.Cmdx("aaa.hash", "file", p))
http.ServeFile(m.Optionv("response").(http.ResponseWriter), m.Optionv("request").(*http.Request), p)
return
}},
"upgrade": &ctx.Command{Name: "upgrade system|script", Help: "服务升级", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
"upgrade": &ctx.Command{Name: "upgrade system|portal|script", Help: "服务升级", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) == 0 {
m.Cmdy("ctx.config", "upgrade", "file")
m.Cmdy("ctx.config", "upgrade")
return
}
if arg[0] == "system" {
if m.Confs("upgrade", arg[0]) {
arg = arg[1:]
m.Confm("upgrade", "file", func(key string, value string) {
arg = append(arg, key)
m.Confm("upgrade", arg[0], func(index int, value string) {
arg = append(arg, value)
})
}
restart := false
for _, link := range arg {
if file := m.Conf("upgrade", []string{"file", link}); file != "" {
if m.Cmd("web.get", "dev", fmt.Sprintf("code/upgrade/%s", link), "save", file); strings.HasPrefix(file, "bin/") {
dir := path.Dir(file)
if _, e = os.Stat(dir); e != nil {
e = os.Mkdir(dir, 0777)
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"),
"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")))
m.Cmd("cli.system", "mv", "bin/bench.new", "bin/bench")