Add Email-Forwarder watch container
This commit is contained in:
parent
88e82286d8
commit
ba53f8bb19
5 changed files with 36 additions and 10 deletions
|
|
@ -21,7 +21,10 @@ import (
|
|||
//
|
||||
// name = Konto-Name oder "all". watch = true -> Delta-Schleife bis Abbruch
|
||||
// (Cutover-Fenster), sonst einmaliger Durchlauf.
|
||||
func RunMigration(name string, watch bool) error {
|
||||
func RunMigration(name string, watch bool, interval time.Duration) error {
|
||||
if interval <= 0 {
|
||||
interval = 60 * time.Second
|
||||
}
|
||||
for {
|
||||
var accounts []Account
|
||||
var err error
|
||||
|
|
@ -32,21 +35,29 @@ func RunMigration(name string, watch bool) error {
|
|||
a, err = GetAccount(name)
|
||||
accounts = []Account{a}
|
||||
}
|
||||
if err != nil {
|
||||
if err != nil && !watch {
|
||||
return err
|
||||
}
|
||||
for _, a := range accounts {
|
||||
if !a.Active {
|
||||
continue
|
||||
}
|
||||
if err := migrateAccount(a); err != nil {
|
||||
return err
|
||||
if err != nil {
|
||||
log.Printf("watch load accounts failed: %v", err)
|
||||
} else {
|
||||
for _, a := range accounts {
|
||||
if !a.Active {
|
||||
continue
|
||||
}
|
||||
if err := migrateAccount(a); err != nil {
|
||||
if !watch {
|
||||
return err
|
||||
}
|
||||
log.Printf("watch migration failed for %s: %v", a.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !watch {
|
||||
return nil
|
||||
}
|
||||
time.Sleep(60 * time.Second)
|
||||
log.Printf("watch sleeping %s", interval)
|
||||
time.Sleep(interval)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue