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