forked from x/icebergs
add some
This commit is contained in:
parent
8d3cc5239e
commit
da8cc86e3a
@ -3,7 +3,6 @@ package gdb
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
@ -43,15 +42,7 @@ const SIGNAL = "signal"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SIGNAL: {Help: "信号量", Actions: ice.MergeActions(ice.Actions{
|
SIGNAL: {Help: "信号量", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _signal_init(m, arg...) }},
|
||||||
if runtime.GOOS == ice.WINDOWS {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_signal_listen(m, 1, mdb.NAME, START, ice.CMD, "runtime")
|
|
||||||
_signal_listen(m, 2, mdb.NAME, RESTART, ice.CMD, "exit 1")
|
|
||||||
_signal_listen(m, 3, mdb.NAME, STOP, ice.CMD, "exit 0")
|
|
||||||
_signal_listen(m, int(syscall.SIGUSR1), mdb.NAME, "info", ice.CMD, "runtime")
|
|
||||||
}},
|
|
||||||
LISTEN: {Name: "listen signal name cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
LISTEN: {Name: "listen signal name cmd", Help: "监听", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_signal_listen(m, kit.Int(m.Option(SIGNAL)), arg...)
|
_signal_listen(m, kit.Int(m.Option(SIGNAL)), arg...)
|
||||||
}},
|
}},
|
||||||
|
25
base/gdb/signal_unix.go
Normal file
25
base/gdb/signal_unix.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package gdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
func _signal_init(m *ice.Message, arg ...string) {
|
||||||
|
_signal_listen(m, 1, mdb.NAME, START, ice.CMD, "runtime")
|
||||||
|
_signal_listen(m, 2, mdb.NAME, RESTART, ice.CMD, "exit 1")
|
||||||
|
_signal_listen(m, 3, mdb.NAME, STOP, ice.CMD, "exit 0")
|
||||||
|
_signal_listen(m, int(syscall.SIGUSR1), mdb.NAME, "info", ice.CMD, "runtime")
|
||||||
|
}
|
||||||
|
func SignalProcess(m *ice.Message, pid string) bool {
|
||||||
|
if proc, err := os.FindProcess(kit.Int(pid)); err == nil && proc.Signal(syscall.SIGUSR1) == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
15
base/gdb/signal_windows.go
Normal file
15
base/gdb/signal_windows.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package gdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func _signal_init(m *ice.Message, arg ...string) {
|
||||||
|
_signal_listen(m, 1, mdb.NAME, START, ice.CMD, "runtime")
|
||||||
|
_signal_listen(m, 2, mdb.NAME, RESTART, ice.CMD, "exit 1")
|
||||||
|
_signal_listen(m, 3, mdb.NAME, STOP, ice.CMD, "exit 0")
|
||||||
|
}
|
||||||
|
func SignalProcess(m *ice.Message, pid string) bool {
|
||||||
|
return false
|
||||||
|
}
|
@ -7,7 +7,6 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
@ -172,7 +171,7 @@ func _dream_check(m *ice.Message, name string) string {
|
|||||||
if pid := m.Cmdx(nfs.CAT, p, kit.Dict(ice.MSG_USERROLE, aaa.TECH)); pid != "" && nfs.Exists(m, "/proc/"+pid) {
|
if pid := m.Cmdx(nfs.CAT, p, kit.Dict(ice.MSG_USERROLE, aaa.TECH)); pid != "" && nfs.Exists(m, "/proc/"+pid) {
|
||||||
m.Info("already exists %v", pid)
|
m.Info("already exists %v", pid)
|
||||||
return ""
|
return ""
|
||||||
} else if proc, err := os.FindProcess(kit.Int(pid)); err == nil && proc.Signal(syscall.SIGUSR1) == nil {
|
} else if gdb.SignalProcess(m, pid) {
|
||||||
m.Info("already exists %v", pid)
|
m.Info("already exists %v", pid)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user