feat:简化main函数

This commit is contained in:
Mmx
2021-07-11 13:05:10 +08:00
parent f3f122a1c5
commit cd15385aec
4 changed files with 44 additions and 31 deletions

View File

@@ -3,6 +3,8 @@ package controllers
import (
"Mmx/global"
"Mmx/util"
"os"
"os/exec"
"time"
)
@@ -19,3 +21,19 @@ func Guardian() {
}()
}
}
func EnterGuardian() {
if global.Config.Settings.Guardian != 0 {
global.Status.Daemon = true
util.Log.Println("[Guardian mode]")
if global.Config.Settings.Daemon {
if err := exec.Command(os.Args[0], "-daemon").Start(); err != nil {
util.ErrHandler(err)
return
}
util.Log.Println("[Daemon mode entered]")
return
}
Guardian()
}
}