mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(irc): log connection errors (#1239)
* add logline for failed connection * modify logging, change debug -> error * don't surface "client called Quit" errors * irc: don't retry Connect() while stopped * fix issue number * don't unlock until state-change complete * Revert "don't unlock until state-change complete" This reverts commit bf107db99bc2758b729a5995c63067f8fdf16aec. --------- Co-authored-by: Shivaram Lingamneni <slingamn@cs.stanford.edu>
This commit is contained in:
parent
fef0da5711
commit
7cb2aaa8a5
1 changed files with 14 additions and 0 deletions
|
@ -25,6 +25,10 @@ import (
|
||||||
"github.com/sasha-s/go-deadlock"
|
"github.com/sasha-s/go-deadlock"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
clientManuallyDisconnected = retry.Unrecoverable(errors.New("IRC client was manually disconnected"))
|
||||||
|
)
|
||||||
|
|
||||||
type channelHealth struct {
|
type channelHealth struct {
|
||||||
m deadlock.RWMutex
|
m deadlock.RWMutex
|
||||||
|
|
||||||
|
@ -219,7 +223,17 @@ func (h *Handler) Run() error {
|
||||||
func() error {
|
func() error {
|
||||||
h.log.Debug().Msgf("connect attempt %d", connectAttempts)
|
h.log.Debug().Msgf("connect attempt %d", connectAttempts)
|
||||||
|
|
||||||
|
// #1239: don't retry if the user manually disconnected with Stop()
|
||||||
|
h.m.RLock()
|
||||||
|
manuallyDisconnected := h.manuallyDisconnected
|
||||||
|
h.m.RUnlock()
|
||||||
|
|
||||||
|
if manuallyDisconnected {
|
||||||
|
return clientManuallyDisconnected
|
||||||
|
}
|
||||||
|
|
||||||
if err := h.client.Connect(); err != nil {
|
if err := h.client.Connect(); err != nil {
|
||||||
|
h.log.Error().Err(err).Msg("client encountered connection error")
|
||||||
connectAttempts++
|
connectAttempts++
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue