added configurable interval

This commit is contained in:
2021-11-19 23:27:51 +01:00
parent 4c8937c707
commit 908fad0923
3 changed files with 28 additions and 12 deletions

View File

@@ -21,6 +21,9 @@ basedir:
march: march:
- x86-64-v3 - x86-64-v3
housekeeping:
interval: 12h
blacklist: blacklist:
packages: packages:
- tensorflow - tensorflow

34
main.go
View File

@@ -40,6 +40,7 @@ var (
db *ent.Client db *ent.Client
journalLog = flag.Bool("journal", false, "Log to systemd journal instead of stdout") journalLog = flag.Bool("journal", false, "Log to systemd journal instead of stdout")
checkInterval = flag.Int("interval", 5, "How often svn2git should be checked in minutes (default: 5)") checkInterval = flag.Int("interval", 5, "How often svn2git should be checked in minutes (default: 5)")
lastHKRun time.Time
) )
func (b *BuildManager) buildWorker(id int) { func (b *BuildManager) buildWorker(id int) {
@@ -511,23 +512,32 @@ func (b *BuildManager) syncWorker() {
} }
// housekeeping // housekeeping
wg := new(sync.WaitGroup) hkDur, err := time.ParseDuration(conf.Housekeeping.Interval)
for _, repo := range repos { if err != nil {
wg.Add(1) log.Warningf("Unable to parse housekeeping duration %s: %v", conf.Housekeeping.Interval, err)
repo := repo hkDur, _ = time.ParseDuration("12h")
go func() { }
err := housekeeping(repo, wg)
if err != nil { if time.Since(lastHKRun) > hkDur {
log.Warningf("[%s] Housekeeping failed: %v", repo, err) lastHKRun = time.Now()
} wg := new(sync.WaitGroup)
}() for _, repo := range repos {
wg.Add(1)
repo := repo
go func() {
err := housekeeping(repo, wg)
if err != nil {
log.Warningf("[%s] housekeeping failed: %v", repo, err)
}
}()
}
wg.Wait()
} }
wg.Wait()
// fetch updates between sync runs // fetch updates between sync runs
b.alpmMutex.Lock() b.alpmMutex.Lock()
check(alpmHandle.Release()) check(alpmHandle.Release())
err := setupChroot() err = setupChroot()
for err != nil { for err != nil {
log.Warningf("Unable to upgrade chroot, trying again later.") log.Warningf("Unable to upgrade chroot, trying again later.")
time.Sleep(time.Minute) time.Sleep(time.Minute)

View File

@@ -84,6 +84,9 @@ type Conf struct {
Repo []string Repo []string
LTO []string `yaml:"lto"` LTO []string `yaml:"lto"`
} }
Housekeeping struct {
Interval string
}
} }
type Globs []string type Globs []string