This commit is contained in:
cdle
2021-08-31 21:10:36 +08:00
parent d33b66ec55
commit ce374b2346
3 changed files with 81 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
package core
import (
"os"
"os/exec"
"strings"
"github.com/astaxie/beego/logs"
)
func Daemon() {
args := os.Args[1:]
execArgs := make([]string, 0)
l := len(args)
for i := 0; i < l; i++ {
if strings.Index(args[i], "-d") == 0 {
continue
}
execArgs = append(execArgs, args[i])
}
proc := exec.Command(os.Args[0], execArgs...)
err := proc.Start()
if err != nil {
panic(err)
}
logs.Info("傻妞以静默形式运行")
os.Exit(0)
}