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
|
Address string
|
||||||
Weight uint
|
Weight uint
|
||||||
LastCheckResult bool
|
LastCheckResult bool
|
||||||
LastCheck time.Time
|
|
||||||
LastCheckMutex sync.RWMutex
|
LastCheckMutex sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,11 +440,8 @@ func handle(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkContentServers() {
|
func checkContentServers() {
|
||||||
checkTime := time.Now().Add(-15 * time.Minute)
|
|
||||||
for _, c := range contentServers {
|
for _, c := range contentServers {
|
||||||
if c.LastCheck.Before(checkTime) {
|
c.check()
|
||||||
c.check()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,13 +503,18 @@ func main() {
|
||||||
Address: p[0],
|
Address: p[0],
|
||||||
Weight: uint(weight),
|
Weight: uint(weight),
|
||||||
LastCheckResult: false,
|
LastCheckResult: false,
|
||||||
LastCheck: time.Date(1970, 0, 0, 0, 0, 0, 0, time.UTC),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: cron this
|
|
||||||
checkContentServers()
|
checkContentServers()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
ticker := time.NewTicker(1 * time.Minute)
|
||||||
|
for _ = range ticker.C {
|
||||||
|
checkContentServers()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
sniAddress = strings.ToLower(*sniAddressOption)
|
sniAddress = strings.ToLower(*sniAddressOption)
|
||||||
|
|
||||||
bogusCertificatePEM, bogusKeyPairPEM := createSelfSignedCertificate()
|
bogusCertificatePEM, bogusKeyPairPEM := createSelfSignedCertificate()
|
||||||
|
|
Loading…
Reference in a new issue