forked from x/icebergs
opt some
This commit is contained in:
parent
8d3bb899b1
commit
634054425d
@ -27,8 +27,7 @@ func init() {
|
|||||||
env = append(env, k, kit.Env(k))
|
env = append(env, k, kit.Env(k))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Option(CMD_ENV, env)
|
m.Optionv(CMD_ENV, env)
|
||||||
|
|
||||||
m.Optionv(CMD_INPUT, os.Stdin)
|
m.Optionv(CMD_INPUT, os.Stdin)
|
||||||
m.Optionv(CMD_OUTPUT, os.Stdout)
|
m.Optionv(CMD_OUTPUT, os.Stdout)
|
||||||
m.Optionv(CMD_ERRPUT, os.Stderr)
|
m.Optionv(CMD_ERRPUT, os.Stderr)
|
||||||
@ -37,12 +36,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Cmd(FOREVER, STOP)
|
m.Cmd(FOREVER, STOP)
|
||||||
if len(arg) > 0 && arg[0] == "space" {
|
if bin := kit.Select(os.Args[0], ice.BIN_ICE_BIN, nfs.ExistsFile(m, ice.BIN_ICE_BIN)); len(arg) > 0 && arg[0] == "space" {
|
||||||
m.Cmdy(FOREVER, kit.Select(os.Args[0], ice.BIN_ICE_BIN, nfs.ExistsFile(m, ice.BIN_ICE_BIN)),
|
m.Cmdy(FOREVER, bin, "space", "dial", ice.DEV, ice.OPS, arg[2:])
|
||||||
"space", "dial", ice.DEV, ice.OPS, arg[2:])
|
|
||||||
} else {
|
} else {
|
||||||
m.Cmdy(FOREVER, kit.Select(os.Args[0], ice.BIN_ICE_BIN, nfs.ExistsFile(m, ice.BIN_ICE_BIN)),
|
m.Cmdy(FOREVER, bin, "serve", START, ice.DEV, "", aaa.USERNAME, aaa.ROOT, aaa.PASSWORD, aaa.ROOT, arg)
|
||||||
"serve", START, ice.DEV, "", aaa.USERNAME, aaa.ROOT, aaa.PASSWORD, aaa.ROOT, arg)
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) {
|
RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -59,14 +56,12 @@ func init() {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
logs.Println("run %s", kit.Join(arg, ice.SP))
|
logs.Println("run %s", kit.Join(arg, ice.SP))
|
||||||
msg := m.Cmd(SYSTEM, arg)
|
if IsSuccess(m.Cmd(SYSTEM, arg)) {
|
||||||
if m.Sleep300ms(); IsSuccess(msg) {
|
|
||||||
logs.Println()
|
|
||||||
logs.Println(ice.EXIT) // 正常退出
|
logs.Println(ice.EXIT) // 正常退出
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
m.Sleep("10s")
|
logs.Println()
|
||||||
logs.Println("what %v", msg.FormatMeta())
|
m.Sleep("1s")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -10,11 +10,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CMD = "cmd"
|
CMD = "cmd"
|
||||||
OSID = "osid"
|
OSID = "osid"
|
||||||
ALPINE = "alpine"
|
UBUNTU = "ubuntu"
|
||||||
CENTOS = "centos"
|
CENTOS = "centos"
|
||||||
UBUNTU = "ubuntu"
|
ALPINE = "alpine"
|
||||||
|
BUSYBOX = "busybox"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MIRRORS = "mirrors"
|
const MIRRORS = "mirrors"
|
||||||
|
@ -162,6 +162,7 @@ const (
|
|||||||
|
|
||||||
var ENV_LIST = []string{
|
var ENV_LIST = []string{
|
||||||
TERM, SHELL, CTX_SHY, CTX_DEV, CTX_OPS, CTX_ARG, CTX_PID, CTX_USER, CTX_SHARE, CTX_RIVER, CTX_DAEMON,
|
TERM, SHELL, CTX_SHY, CTX_DEV, CTX_OPS, CTX_ARG, CTX_PID, CTX_USER, CTX_SHARE, CTX_RIVER, CTX_DAEMON,
|
||||||
|
"DOCKER_HOST",
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -185,6 +185,9 @@ func init() {
|
|||||||
arg = kit.Split(arg[0])
|
arg = kit.Split(arg[0])
|
||||||
}
|
}
|
||||||
_system_exec(m, _system_cmd(m, arg...))
|
_system_exec(m, _system_cmd(m, arg...))
|
||||||
|
if IsSuccess(m) {
|
||||||
|
m.SetAppend()
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func _space_handle(m *ice.Message, safe bool, frame *Frame, c *websocket.Conn, n
|
|||||||
socket, msg := c, m.Spawn(b)
|
socket, msg := c, m.Spawn(b)
|
||||||
target := kit.Simple(msg.Optionv(ice.MSG_TARGET))
|
target := kit.Simple(msg.Optionv(ice.MSG_TARGET))
|
||||||
source := kit.Simple(msg.Optionv(ice.MSG_SOURCE), name)
|
source := kit.Simple(msg.Optionv(ice.MSG_SOURCE), name)
|
||||||
msg.Log("recv", "%v->%v %s %v", source, target, msg.Detailv(), msg.FormatMeta())
|
msg.Log("recv", "%v<-%v %s %v", target, source, msg.Detailv(), msg.FormatMeta())
|
||||||
|
|
||||||
if len(target) == 0 { // 执行命令
|
if len(target) == 0 { // 执行命令
|
||||||
if msg.Optionv(ice.MSG_HANDLE, ice.TRUE); safe { // 下行命令
|
if msg.Optionv(ice.MSG_HANDLE, ice.TRUE); safe { // 下行命令
|
||||||
|
1
conf.go
1
conf.go
@ -294,6 +294,7 @@ const ( // ctx
|
|||||||
INDEX = "index"
|
INDEX = "index"
|
||||||
)
|
)
|
||||||
const ( // mdb
|
const ( // mdb
|
||||||
|
AAA = "aaa"
|
||||||
MDB = "mdb"
|
MDB = "mdb"
|
||||||
KEY = "key"
|
KEY = "key"
|
||||||
VALUE = "value"
|
VALUE = "value"
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
|
||||||
"shylinux.com/x/icebergs/base/gdb"
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
@ -180,7 +179,7 @@ const INSTALL = "install"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
INSTALL: {Name: "install name port path auto download", Help: "安装", Meta: kit.Dict(), Actions: ice.MergeActions(ice.Actions{
|
INSTALL: {Name: "install name port path:text auto download", Help: "安装", Meta: kit.Dict(), Actions: ice.MergeActions(ice.Actions{
|
||||||
web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
web.DOWNLOAD: {Name: "download link path", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_install_download(m)
|
_install_download(m)
|
||||||
}},
|
}},
|
||||||
@ -205,15 +204,7 @@ func init() {
|
|||||||
_install_stop(m, arg...)
|
_install_stop(m, arg...)
|
||||||
}},
|
}},
|
||||||
gdb.DEBUG: {Name: "debug", Help: "调试", Hand: func(m *ice.Message, arg ...string) {
|
gdb.DEBUG: {Name: "debug", Help: "调试", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if cmd := "web.code.xterm"; len(arg) > 0 && arg[0] == ice.RUN {
|
ProcessXterm(m, []string{mdb.TYPE, "gdb"})
|
||||||
if len(arg) > 2 && arg[1] == ctx.ACTION && arg[2] == mdb.CREATE {
|
|
||||||
arg = append(arg, mdb.TYPE, "gdb")
|
|
||||||
}
|
|
||||||
m.Cmdy(cmd, arg[1:])
|
|
||||||
} else {
|
|
||||||
m.Cmdy(ctx.COMMAND, cmd)
|
|
||||||
m.ProcessField(m.ActionKey(), ice.RUN)
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
nfs.TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_install_trash(m, arg...)
|
_install_trash(m, arg...)
|
||||||
|
@ -2,6 +2,7 @@ package code
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -10,10 +11,12 @@ import (
|
|||||||
|
|
||||||
pty "shylinux.com/x/creackpty"
|
pty "shylinux.com/x/creackpty"
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
"shylinux.com/x/icebergs/base/tcp"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
@ -25,9 +28,7 @@ func _xterm_socket(m *ice.Message, h, t string) {
|
|||||||
}
|
}
|
||||||
func _xterm_get(m *ice.Message, h string, must bool) *os.File {
|
func _xterm_get(m *ice.Message, h string, must bool) *os.File {
|
||||||
t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE)
|
t := mdb.HashSelectField(m, m.Option(mdb.HASH, h), mdb.TYPE)
|
||||||
m.Debug("what %v", h)
|
|
||||||
if f, ok := mdb.HashTarget(m, h, func() ice.Any {
|
if f, ok := mdb.HashTarget(m, h, func() ice.Any {
|
||||||
m.Debug("what %v", h)
|
|
||||||
if !must {
|
if !must {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -76,6 +77,7 @@ func init() {
|
|||||||
c.Close()
|
c.Close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
m.Conf("", mdb.HASH, "")
|
||||||
}},
|
}},
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch mdb.HashInputs(m, arg); arg[0] {
|
switch mdb.HashInputs(m, arg); arg[0] {
|
||||||
@ -96,6 +98,19 @@ func init() {
|
|||||||
})
|
})
|
||||||
mdb.HashRemove(m)
|
mdb.HashRemove(m)
|
||||||
}},
|
}},
|
||||||
|
"install": {Name: "install", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if m.Option(mdb.HASH) != "" {
|
||||||
|
u := web.OptionUserWeb(m)
|
||||||
|
host := strings.Split(u.Host, ice.DF)[0]
|
||||||
|
if host == tcp.LOCALHOST {
|
||||||
|
host = m.Cmd(tcp.HOST).Append(aaa.IP)
|
||||||
|
}
|
||||||
|
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
|
||||||
|
cmd := kit.Renders(`export ctx_dev={{.Option "httphost"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}`, m)
|
||||||
|
_xterm_get(m, m.Option(mdb.HASH), true).Write([]byte(cmd + "\n"))
|
||||||
|
}
|
||||||
|
m.ProcessHold()
|
||||||
|
}},
|
||||||
"rename": {Name: "rename", Help: "重命名", Hand: func(m *ice.Message, arg ...string) {
|
"rename": {Name: "rename", Help: "重命名", Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashModify(m, arg)
|
mdb.HashModify(m, arg)
|
||||||
}},
|
}},
|
||||||
@ -119,9 +134,9 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcessXterm(m *ice.Message, bin string, arg ...string) {
|
func ProcessXterm(m *ice.Message, args []string, arg ...string) {
|
||||||
if len(arg) > 2 && arg[0] == ice.RUN && arg[1] == ctx.ACTION && arg[2] == mdb.CREATE {
|
if len(arg) > 2 && arg[0] == ice.RUN && arg[1] == ctx.ACTION && arg[2] == mdb.CREATE {
|
||||||
arg = append(arg, mdb.TYPE, bin)
|
arg = append(arg, args...)
|
||||||
}
|
}
|
||||||
ctx.ProcessField(m, "web.code.xterm", nil, arg...)
|
ctx.ProcessField(m, "web.code.xterm", nil, arg...)
|
||||||
}
|
}
|
||||||
|
8
misc.go
8
misc.go
@ -263,12 +263,10 @@ func (c *Context) _command(m *Message, cmd *Command, key string, arg ...string)
|
|||||||
if m._target = kit.FileLine(cmd.Hand, 3); cmd.RawHand != nil {
|
if m._target = kit.FileLine(cmd.Hand, 3); cmd.RawHand != nil {
|
||||||
m._target = kit.Format(cmd.RawHand)
|
m._target = kit.Format(cmd.RawHand)
|
||||||
}
|
}
|
||||||
if key == "select" {
|
if fileline := kit.Select(m._target, m._source, m.target.Name == MDB); key == "select" {
|
||||||
m.Log(LOG_CMDS, "%s.%s %d %v %v", c.Name, key, len(arg), arg, m.Optionv(MSG_FIELDS),
|
m.Log(LOG_CMDS, "%s.%s %d %v %v", c.Name, key, len(arg), arg, m.Optionv(MSG_FIELDS), logs.FileLineMeta(fileline))
|
||||||
logs.FileLineMeta(kit.Select(m._target, m._source, m.target.Name == MDB)))
|
|
||||||
} else {
|
} else {
|
||||||
m.Log(LOG_CMDS, "%s.%s %d %v", c.Name, key, len(arg), arg,
|
m.Log(LOG_CMDS, "%s.%s %d %v", c.Name, key, len(arg), arg, logs.FileLineMeta(fileline))
|
||||||
logs.FileLineMeta(kit.Select(m._target, m._source, m.target.Name == MDB)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Hand != nil {
|
if cmd.Hand != nil {
|
||||||
|
@ -3,6 +3,7 @@ package node
|
|||||||
import (
|
import (
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -29,7 +30,7 @@ func (s compile) List(m *ice.Message, arg ...string) {
|
|||||||
s.Code.Source(m, "", arg...)
|
s.Code.Source(m, "", arg...)
|
||||||
}
|
}
|
||||||
func (s compile) Xterm(m *ice.Message, arg ...string) {
|
func (s compile) Xterm(m *ice.Message, arg ...string) {
|
||||||
s.Code.Xterm(m, NODE, arg...)
|
s.Code.Xterm(m, []string{mdb.TYPE, NODE}, arg...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.CodeCtxCmd(compile{}) }
|
func init() { ice.CodeCtxCmd(compile{}) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user