1
0
forked from x/icebergs

opt build.sh

This commit is contained in:
shaoying 2019-12-26 09:22:46 +08:00
parent c2c5c1770c
commit aba7e870ac
10 changed files with 71 additions and 29 deletions

View File

@ -2,6 +2,11 @@
icebergs是一个后端框架通过模块化、集群化实现资源的无限的扩展与自由的组合。
一键创建项目
```
curl -s https://raw.githubusercontent.com/shylinux/icebergs/master/demo/build.sh | sh miss
```
## 1 原型 type.go
### 1.1 msg.Detail
### 1.2 msg.Option

View File

@ -125,7 +125,7 @@ func Run(arg ...string) string {
arg = os.Args[1:]
}
if len(arg) == 0 {
arg = append(arg, os.Getenv("ice_serve"))
arg = append(arg, WEB_SERVE)
}
frame := &Frame{}

View File

@ -74,11 +74,11 @@ var Index = &ice.Context{Name: "gdb", Help: "事件模块",
"pid": "var/run/shy.pid",
},
kit.MDB_HASH: map[string]interface{}{
"2": []interface{}{"exit"},
"3": []interface{}{"exit", "1"},
"15": []interface{}{"exit", "1"},
"30": []interface{}{"exit"},
"31": []interface{}{"exit", "1"},
"2": []interface{}{"exit", "1"},
"3": []interface{}{"exit"},
"15": []interface{}{"exit"},
"30": []interface{}{"exit", "1"},
"31": []interface{}{"exit"},
"28": "WINCH",
},
kit.MDB_LIST: map[string]interface{}{},

View File

@ -427,6 +427,9 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
"name", m.Conf(ice.CLI_RUNTIME, "boot.hostname"),
"user", m.Conf(ice.CLI_RUNTIME, "boot.username"),
))
if _, e := os.Stat("usr/volcanos"); e != nil {
m.Cmd("cli.system", "git", "clone", "https://github.com/shylinux/volcanos", "usr/volcanos")
}
m.Target().Start(m, kit.Select("self", arg, 0))
}},
ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List(
@ -953,6 +956,18 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
})
}
}},
"/static/volcanos/plugin/github.com/": {Name: "/space/", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
file := strings.TrimPrefix(cmd, "/static/volcanos/")
if _, e := os.Stat(path.Join("usr/volcanos", file)); e != nil {
m.Cmd("cli.system", "git", "clone", "https://"+strings.Join(strings.Split(cmd, "/")[4:7], "/"),
path.Join("usr/volcanos", strings.Join(strings.Split(cmd, "/")[3:7], "/")))
}
m.Push("_output", "void")
r := m.Optionv("request").(*http.Request)
w := m.Optionv("response").(http.ResponseWriter)
http.ServeFile(w, r, path.Join("usr/volcanos", file))
}},
},
}

View File

@ -21,13 +21,15 @@ var Index = &ice.Context{Name: "team", Help: "团队模块",
},
Commands: map[string]*ice.Command{
"miss": {Name: "miss", Help: "任务", Meta: map[string]interface{}{
"exports": []interface{}{"you", "name"},
"display": "github.com/shylinux/context/usr/librarys/code",
"detail": []interface{}{"启动", "停止"},
"exports": []interface{}{"you", "name"},
}, List: kit.List(
kit.MDB_INPUT, "text", "value", "", "name", "name",
kit.MDB_INPUT, "text", "value", "", "name", "type",
kit.MDB_INPUT, "button", "value", "创建", "action", "auto",
), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
return
if len(arg) > 1 {
switch arg[1] {
case "启动":

View File

@ -1,3 +1,2 @@
all:
@echo && date
sh build.sh build && sh build.sh restart
go build -o bin/ice.bin main.go && chmod u+x bin/ice.bin && ./load.sh restart

View File

@ -1,9 +1,6 @@
#! /bin/sh
export ice_app=${ice_app:="ice.app"}
export ice_err=${ice_err:="boot.log"}
export ice_serve=${ice_serve:="web.serve"}
export ice_can=${ice_can:="https://github.com/shylinux/volcanos"}
ice_sh=${ice_sh:="ice.sh"}
prepare() {
[ -f main.go ] || cat >> main.go <<END
@ -23,28 +20,43 @@ END
[ -f go.mod ] || go mod init ${PWD##**/}
[ -f Makefile ] || cat >> Makefile <<END
all:
sh build.sh build && sh build.sh restart
END
}
build() {
prepare && go build -o bin/shy main.go
}
[ -f ${ice_sh} ] || cat >> ${ice_sh} <<END
#! /bin/sh
export PATH=\${PWD}/bin:\$PATH
prepare() {
which ice.bin && return
curl -s https://shylinux.com/publish/ice.bin -o bin/ice.bin
}
start() {
[ -z "$@" ] && ( [ -d usr/volcanos ] || git clone $ice_can usr/volcanos )
while true; do
date && $ice_app $@ 2>$ice_err && echo -e "\n\nrestarting..." || break
prepare && while true; do
date && ice.bin \$@ 2>boot.log && break || echo -e "\n\nrestarting..."
done
}
restart() {
kill -2 `cat var/run/shy.pid`
kill -2 \`cat var/run/shy.pid\`
}
shutdown() {
kill -3 `cat var/run/shy.pid`
kill -3 \`cat var/run/shy.pid\`
}
cmd=\$1 && shift
[ -z "\$cmd" ] && cmd=start
\$cmd \$*
END
chmod u+x ${ice_sh}
[ -f Makefile ] || cat >> Makefile <<END
all:
go build -o bin/ice.bin main.go && chmod u+x bin/ice.bin && ./${ice_sh} restart
END
}
build() {
[ "$1" != "" ] && mdkir $1 && cd $1
prepare && go build -o bin/ice.bin main.go && chmod u+x bin/ice.bin && ./${ice_sh}
}
cmd=$1 && shift
[ -z "$cmd" ] && cmd=start
[ -z "$cmd" ] && cmd=build
$cmd $*

View File

@ -4,7 +4,7 @@ go 1.13
require (
github.com/shylinux/icebergs v0.0.0-20191212145348-fe6226481eaa
github.com/shylinux/toolkits v0.0.0-20191212145555-d32eaba90a9e
github.com/shylinux/toolkits v0.0.0-20191225132906-3c11db083b5b
)
replace (

6
go.mod
View File

@ -2,4 +2,8 @@ module github.com/shylinux/icebergs
go 1.13
require github.com/shylinux/toolkits v0.0.0-20191225132906-3c11db083b5b
require (
github.com/gomarkdown/markdown v0.0.0-20191207194928-fbea82c4bb03
github.com/gorilla/websocket v1.4.1
github.com/shylinux/toolkits v0.0.0-20191225132906-3c11db083b5b
)

5
go.sum
View File

@ -1,2 +1,7 @@
github.com/gomarkdown/markdown v0.0.0-20191207194928-fbea82c4bb03 h1:m13UZm540+0yrpGOIXd7q4AvPGQPSTo+2jxrBK26o64=
github.com/gomarkdown/markdown v0.0.0-20191207194928-fbea82c4bb03/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/shylinux/toolkits v0.0.0-20191225132906-3c11db083b5b h1:BXDEMcpHmwuwoqY/NWehDs11GOy2x+2MS7Xfihb3zFY=
github.com/shylinux/toolkits v0.0.0-20191225132906-3c11db083b5b/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=