2020-09-12 15:23:25 +00:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
2021-02-21 20:23:06 +00:00
|
|
|
"go.jolheiser.com/beaver"
|
|
|
|
"go.jolheiser.com/vanity/service"
|
2020-09-12 15:23:25 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"go.jolheiser.com/vanity/flags"
|
|
|
|
)
|
|
|
|
|
2021-02-21 20:23:06 +00:00
|
|
|
var (
|
|
|
|
svc service.Service
|
|
|
|
lastUpdate time.Time
|
|
|
|
canUpdate bool
|
|
|
|
)
|
2020-09-12 15:23:25 +00:00
|
|
|
|
|
|
|
func cronStart() {
|
2021-02-21 20:23:06 +00:00
|
|
|
canUpdate = true
|
2020-09-12 15:23:25 +00:00
|
|
|
ticker := time.NewTicker(flags.Interval)
|
|
|
|
for {
|
|
|
|
<-ticker.C
|
2021-02-21 20:23:06 +00:00
|
|
|
if !flags.Manual && canUpdate {
|
|
|
|
beaver.Debug("Running package update...")
|
|
|
|
updateCache()
|
|
|
|
beaver.Debugf("Finished package update: %s", cache.Packages.Names())
|
|
|
|
lastUpdate = time.Now()
|
2020-09-12 15:23:25 +00:00
|
|
|
}
|
2021-02-21 20:23:06 +00:00
|
|
|
canUpdate = true
|
2020-09-12 15:23:25 +00:00
|
|
|
}
|
|
|
|
}
|