test reload rules for offline client

This commit is contained in:
shoopea 2020-02-10 10:58:16 +08:00
parent 140b420652
commit 3709bbc1f9

View File

@ -731,7 +731,9 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) {
func MQTidyKeepAliveWorker() {
//log.Printf("MQTidyKeepAliveWorker : Starting.")
var reloadRules bool
for true {
reloadRules = false
t := time.Now()
muxClients.Lock()
for id, clt := range clients {
@ -756,6 +758,7 @@ func MQTidyKeepAliveWorker() {
}
TGCmdQueue <- cmd
clt.Active = false
reloadRules = true
} else if clt.Active {
//log.Printf("MQTidyKeepAliveWorker : Client %s is active.\n", clt.Login)
} else {
@ -764,6 +767,12 @@ func MQTidyKeepAliveWorker() {
clt.Mux.Unlock()
}
muxClients.Unlock()
if reloadRules {
log.Printf("Offline client, reloading rules ..\n")
resetMsgParsingRules()
msgParsingRules, err = loadMsgParsingRules()
logOnError(err, "MQTidyKeepAliveWorker : message parsing rules")
}
time.Sleep(time.Until(t.Add(time.Second)))
}
log.Printf("MQTidyKeepAliveWorker : Closing.")