mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
fix(email): always use configured delay for notifications (#536)
This commit is contained in:
parent
adaeb3388f
commit
46f43764d2
1 changed files with 4 additions and 5 deletions
|
@ -110,6 +110,10 @@ func (e *emailTypeNotifier) sendEntries(entries []*log.Entry) {
|
|||
// Do the sending in a separate goroutine so we don't block the main process.
|
||||
msg := e.buildMessage(entries)
|
||||
go func() {
|
||||
if e.delay > 0 {
|
||||
time.Sleep(e.delay)
|
||||
}
|
||||
|
||||
var auth smtp.Auth
|
||||
if e.User != "" {
|
||||
auth = smtp.PlainAuth("", e.User, e.Password, e.Server)
|
||||
|
@ -133,10 +137,6 @@ func (e *emailTypeNotifier) SendNotification() {
|
|||
return
|
||||
}
|
||||
|
||||
if e.delay > 0 {
|
||||
time.Sleep(e.delay)
|
||||
}
|
||||
|
||||
e.sendEntries(e.entries)
|
||||
e.entries = nil
|
||||
}
|
||||
|
@ -149,7 +149,6 @@ func (e *emailTypeNotifier) Fire(entry *log.Entry) error {
|
|||
if e.entries != nil {
|
||||
e.entries = append(e.entries, entry)
|
||||
} else {
|
||||
// Log output generated outside a cycle is sent immediately.
|
||||
e.sendEntries([]*log.Entry{entry})
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue