feat:守护增加掉线提示

This commit is contained in:
Mmx
2021-07-11 13:15:23 +08:00
parent 5f9ded64a8
commit 69d4b9f422
2 changed files with 5 additions and 3 deletions

View File

@@ -8,6 +8,6 @@ func init() {
goDaemon := flag.Bool("daemon", false, "") goDaemon := flag.Bool("daemon", false, "")
flag.Parse() flag.Parse()
if *goDaemon { if *goDaemon {
Guardian() Guardian(false)
} }
} }

View File

@@ -8,14 +8,16 @@ import (
"time" "time"
) )
func Guardian() { func Guardian(output bool) {
for { for {
global.Status.Output = output
time.Sleep(time.Duration(global.Config.Settings.Guardian) * time.Second) time.Sleep(time.Duration(global.Config.Settings.Guardian) * time.Second)
go func() { go func() {
defer func() { defer func() {
_ = recover() _ = recover()
}() }()
if !util.Checker.NetOk() { if !util.Checker.NetOk() {
util.Log.Println("Network down, trying to login")
_ = Login(false) _ = Login(false)
} }
}() }()
@@ -34,6 +36,6 @@ func EnterGuardian() {
util.Log.Println("[Daemon mode entered]") util.Log.Println("[Daemon mode entered]")
return return
} }
Guardian() Guardian(true)
} }
} }