mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
fix(shoutrrr): display errors on init failure (#558)
This commit is contained in:
parent
86b1b0468a
commit
70bd4e2c8b
2 changed files with 11 additions and 3 deletions
|
|
@ -47,7 +47,9 @@ func NewNotifier(c *cobra.Command) *Notifier {
|
||||||
default:
|
default:
|
||||||
log.Fatalf("Unknown notification type %q", t)
|
log.Fatalf("Unknown notification type %q", t)
|
||||||
}
|
}
|
||||||
n.types = append(n.types, tn)
|
if tn != nil {
|
||||||
|
n.types = append(n.types, tn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n
|
return n
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,11 @@ func newShoutrrrNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Noti
|
||||||
flags := c.PersistentFlags()
|
flags := c.PersistentFlags()
|
||||||
|
|
||||||
urls, _ := flags.GetStringArray("notification-url")
|
urls, _ := flags.GetStringArray("notification-url")
|
||||||
r, _ := shoutrrr.CreateSender(urls...)
|
r, err := shoutrrr.CreateSender(urls...)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to initialize Shoutrrr notifications: %s\n", err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
n := &shoutrrrTypeNotifier{
|
n := &shoutrrrTypeNotifier{
|
||||||
Urls: urls,
|
Urls: urls,
|
||||||
|
|
@ -52,8 +56,10 @@ func (e *shoutrrrTypeNotifier) buildMessage(entries []*log.Entry) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *shoutrrrTypeNotifier) sendEntries(entries []*log.Entry) {
|
func (e *shoutrrrTypeNotifier) sendEntries(entries []*log.Entry) {
|
||||||
// Do the sending in a separate goroutine so we don't block the main process.
|
|
||||||
msg := e.buildMessage(entries)
|
msg := e.buildMessage(entries)
|
||||||
|
|
||||||
|
// Do the sending in a separate goroutine so we don't block the main process.
|
||||||
go func() {
|
go func() {
|
||||||
errs := e.Router.Send(msg, nil)
|
errs := e.Router.Send(msg, nil)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue