Added content server check ticker
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bc3dc90593
commit
1627c1aea8
|
@ -45,7 +45,6 @@ type ContentServer struct {
|
|||
Address string
|
||||
Weight uint
|
||||
LastCheckResult bool
|
||||
LastCheck time.Time
|
||||
LastCheckMutex sync.RWMutex
|
||||
}
|
||||
|
||||
|
@ -441,11 +440,8 @@ func handle(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func checkContentServers() {
|
||||
checkTime := time.Now().Add(-15 * time.Minute)
|
||||
for _, c := range contentServers {
|
||||
if c.LastCheck.Before(checkTime) {
|
||||
c.check()
|
||||
}
|
||||
c.check()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,13 +503,18 @@ func main() {
|
|||
Address: p[0],
|
||||
Weight: uint(weight),
|
||||
LastCheckResult: false,
|
||||
LastCheck: time.Date(1970, 0, 0, 0, 0, 0, 0, time.UTC),
|
||||
})
|
||||
}
|
||||
|
||||
//TODO: cron this
|
||||
checkContentServers()
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(1 * time.Minute)
|
||||
for _ = range ticker.C {
|
||||
checkContentServers()
|
||||
}
|
||||
}()
|
||||
|
||||
sniAddress = strings.ToLower(*sniAddressOption)
|
||||
|
||||
bogusCertificatePEM, bogusKeyPairPEM := createSelfSignedCertificate()
|
||||
|
|
Loading…
Reference in a new issue