Update chatbot deadlock watcher

This commit is contained in:
Noah 2023-09-10 12:02:34 -07:00
parent 239e80a7cc
commit 1acc626819

View File

@ -31,11 +31,13 @@ func (h *BotHandlers) watchForDeadlock() {
for { for {
time.Sleep(15 * time.Second) time.Sleep(15 * time.Second)
go func() {
h.client.Send(messages.Message{ h.client.Send(messages.Message{
Action: messages.ActionMessage, Action: messages.ActionMessage,
Channel: "@" + h.client.Username(), Channel: "@" + h.client.Username(),
Message: "deadlock ping", Message: "deadlock ping",
}) })
}()
// Has it been a while since our last ping? // Has it been a while since our last ping?
if time.Since(h.deadlockLastOK) > deadlockTTL { if time.Since(h.deadlockLastOK) > deadlockTTL {
@ -50,6 +52,7 @@ func (h *BotHandlers) watchForDeadlock() {
func (h *BotHandlers) onMessageFromSelf(msg messages.Message) { func (h *BotHandlers) onMessageFromSelf(msg messages.Message) {
// If it is our own DM channel thread, it's for deadlock detection. // If it is our own DM channel thread, it's for deadlock detection.
if msg.Channel == "@"+h.client.Username() { if msg.Channel == "@"+h.client.Username() {
log.Info("(Deadlock test) got echo from self, server still seems OK")
h.deadlockLastOK = time.Now() h.deadlockLastOK = time.Now()
} }
} }