You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
backy/pkg/backy/cron.go

29 lines
531 B

// cron.go
// Copyright (C) Andrew Woodlee 2023
// License: Apache-2.0
package backy
import (
"strings"
"time"
"github.com/go-co-op/gocron"
)
func (conf *BackyConfigFile) Cron() {
s := gocron.NewScheduler(time.Local)
s.TagsUnique()
for _, config := range conf.CmdConfigLists {
if strings.TrimSpace(config.Cron) != "" {
_, err := s.CronWithSeconds(config.Cron).Tag(config.Name).Do(func(cron string) {
conf.RunBackyConfig(cron)
}, config.Cron)
if err != nil {
panic(err)
}
}
}
s.StartBlocking()
}