send mail if debug on

This commit is contained in:
shoopea 2023-08-01 09:35:45 +02:00
parent 8ecde237b1
commit 9c152943cd
4 changed files with 16 additions and 13 deletions

View File

@ -90,6 +90,7 @@ func (a *AdminConfig) Run() {
log.WithFields(log.Fields{"call": "cron.AddFunc", "error": err}).Errorf("")
}
c.Start()
log.WithFields(log.Fields{"call": "cron.Start"}).Debugf("cron started")
// Listen for the interrupt signal.
<-ctx.Done()

16
app.go
View File

@ -281,47 +281,47 @@ func (a *App) RunSchedule(schedule string, now time.Time) error {
}
func (a *App) Run(now time.Time) error {
func (a *App) Run(now time.Time) (string, error) {
log.WithFields(log.Fields{"app": a.name, "now": now}).Debugf("starting")
defer log.WithFields(log.Fields{"app": a.name, "now": now}).Debugf("done")
if err := a.SanityCheck(); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "call": "SanityCheck", "error": err}).Errorf("")
return err
return "", err
}
schedule, err := a.NextSchedule(now)
if err != nil {
log.WithFields(log.Fields{"app": a.name, "call": "NextSchedule", "error": err}).Errorf("")
return err
return "", err
}
log.WithFields(log.Fields{"app": a.name, "now": now, "schedule": schedule}).Debugf("schedule")
if schedule != "" {
if err := a.RunSchedule(schedule, now); err != nil {
log.WithFields(log.Fields{"app": a.name, "call": "NextSchedule", "error": err}).Errorf("")
return err
return "", err
}
}
for _, src := range a.sources {
if err := src.SetManaged(true); err != nil {
log.WithFields(log.Fields{"app": a.name, "call": "src.SetManaged", "error": err}).Errorf("")
return err
return "", err
}
}
if err := a.Transfer(); err != nil {
log.WithFields(log.Fields{"app": a.name, "call": "Transfer", "error": err}).Errorf("")
return err
return "", err
}
if err := a.Cleanup(now); err != nil {
log.WithFields(log.Fields{"app": a.name, "call": "Cleanup", "error": err}).Errorf("")
return err
return "", err
}
return nil
return schedule, nil
}
func (a *App) NextSchedule(now time.Time) (string, error) {

View File

@ -181,8 +181,10 @@ func (c *Config) Run() {
for _, a := range cfg.apps {
wg.Add(1)
go func(app *App) {
if err := app.Run(e.startTime); err != nil {
if sched, err := app.Run(e.startTime); err != nil {
e.AddItem(fmt.Sprintf(" - App : Error running %s (%s)", app.name, err))
} else if *debug {
e.AddItem(fmt.Sprintf(" - App : Success backing up %s (%s)", app.name, sched))
}
wg.Done()
}(a)

View File

@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "54a16bd"
var githash = "8ecde23"
var branch = "v2"
var buildstamp = "2023-07-31_23:22:29"
var commits = "78"
var version = "54a16bd-b78 - 2023-07-31_23:22:29"
var buildstamp = "2023-08-01_07:34:30"
var commits = "79"
var version = "8ecde23-b79 - 2023-08-01_07:34:30"