update
This commit is contained in:
+15
-13
@@ -8,7 +8,6 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
@@ -38,6 +37,7 @@ func Daemon() {
|
|||||||
}
|
}
|
||||||
logs.Info(sillyGirl.Get("name", "傻妞") + "以静默形式运行")
|
logs.Info(sillyGirl.Get("name", "傻妞") + "以静默形式运行")
|
||||||
os.WriteFile(pidf, []byte(fmt.Sprintf("%d", proc.Process.Pid)), 0o644)
|
os.WriteFile(pidf, []byte(fmt.Sprintf("%d", proc.Process.Pid)), 0o644)
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitPull(filename string) (bool, error) {
|
func GitPull(filename string) (bool, error) {
|
||||||
@@ -69,19 +69,21 @@ func CompileCode() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func killp() {
|
func killp() {
|
||||||
data, _ := os.ReadFile(pidf)
|
// data, _ := os.ReadFile(pidf)
|
||||||
pid := Int(string(data))
|
// pid := Int(string(data))
|
||||||
syscall.Kill(-pid, syscall.SIGKILL)
|
// if pid > 0 {
|
||||||
// pids, err := ppid()
|
// syscall.Kill(-pid, syscall.SIGKILL)
|
||||||
// if err == nil {
|
|
||||||
// if len(pids) == 0 {
|
|
||||||
// return
|
|
||||||
// } else {
|
|
||||||
// exec.Command("sh", "-c", "kill -9 "+strings.Join(pids, " ")).Output()
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// return
|
|
||||||
// }
|
// }
|
||||||
|
pids, err := ppid()
|
||||||
|
if err == nil {
|
||||||
|
if len(pids) == 0 {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
exec.Command("sh", "-c", "kill -9 "+strings.Join(pids, " ")).Output()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ppid() ([]string, error) {
|
func ppid() ([]string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user