forked from ALHP/ALHP.GO
added configurable interval
This commit is contained in:
@@ -21,6 +21,9 @@ basedir:
|
|||||||
march:
|
march:
|
||||||
- x86-64-v3
|
- x86-64-v3
|
||||||
|
|
||||||
|
housekeeping:
|
||||||
|
interval: 12h
|
||||||
|
|
||||||
blacklist:
|
blacklist:
|
||||||
packages:
|
packages:
|
||||||
- tensorflow
|
- tensorflow
|
||||||
|
14
main.go
14
main.go
@@ -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,6 +512,14 @@ func (b *BuildManager) syncWorker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// housekeeping
|
// housekeeping
|
||||||
|
hkDur, err := time.ParseDuration(conf.Housekeeping.Interval)
|
||||||
|
if err != nil {
|
||||||
|
log.Warningf("Unable to parse housekeeping duration %s: %v", conf.Housekeeping.Interval, err)
|
||||||
|
hkDur, _ = time.ParseDuration("12h")
|
||||||
|
}
|
||||||
|
|
||||||
|
if time.Since(lastHKRun) > hkDur {
|
||||||
|
lastHKRun = time.Now()
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
for _, repo := range repos {
|
for _, repo := range repos {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@@ -518,16 +527,17 @@ func (b *BuildManager) syncWorker() {
|
|||||||
go func() {
|
go func() {
|
||||||
err := housekeeping(repo, wg)
|
err := housekeeping(repo, wg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[%s] Housekeeping failed: %v", repo, err)
|
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)
|
||||||
|
Reference in New Issue
Block a user