Update chatbot deadlock watcher
This commit is contained in:
parent
239e80a7cc
commit
1acc626819
|
@ -31,11 +31,13 @@ func (h *BotHandlers) watchForDeadlock() {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
time.Sleep(15 * time.Second)
|
time.Sleep(15 * time.Second)
|
||||||
h.client.Send(messages.Message{
|
go func() {
|
||||||
Action: messages.ActionMessage,
|
h.client.Send(messages.Message{
|
||||||
Channel: "@" + h.client.Username(),
|
Action: messages.ActionMessage,
|
||||||
Message: "deadlock ping",
|
Channel: "@" + h.client.Username(),
|
||||||
})
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user