diff --git a/README.md b/README.md index ce3677f2..737c228e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/base.go b/base.go index 92ea51fa..85526bc4 100644 --- a/base.go +++ b/base.go @@ -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{} diff --git a/base/gdb/gdb.go b/base/gdb/gdb.go index 691333a5..0964dd95 100644 --- a/base/gdb/gdb.go +++ b/base/gdb/gdb.go @@ -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{}{}, diff --git a/base/web/web.go b/base/web/web.go index 33b04d53..a99c788c 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -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)) + }}, }, } diff --git a/core/team/team.go b/core/team/team.go index 9d51a9a0..43c55919 100644 --- a/core/team/team.go +++ b/core/team/team.go @@ -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 "启动": diff --git a/demo/Makefile b/demo/Makefile index b03c4690..94e5404e 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -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 diff --git a/demo/build.sh b/demo/build.sh index eeb1a674..43b127a2 100755 --- a/demo/build.sh +++ b/demo/build.sh @@ -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 <> Makefile <> ${ice_sh} <$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 <