Browse Source

caddytls: Move initial storage clean op into goroutine

Sometimes this operation can take a while (we observed 7 minutes
recently, with a large, globally-distributed storage backend).
master
Matthew Holt 5 years ago
parent
commit
efc0cc5e85
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 8
      modules/caddytls/tls.go

8
modules/caddytls/tls.go

@ -373,9 +373,9 @@ func (t *TLS) AllMatchingCertificates(san string) []certmagic.Certificate {
return t.certCache.AllMatchingCertificates(san) return t.certCache.AllMatchingCertificates(san)
} }
// keepStorageClean immediately cleans up all known storage units // keepStorageClean starts a goroutine that immediately cleans up all
// if it was not recently done, and starts a goroutine that runs // known storage units if it was not recently done, and then runs the
// the operation at every tick from t.storageCleanTicker. // operation at every tick from t.storageCleanTicker.
func (t *TLS) keepStorageClean() { func (t *TLS) keepStorageClean() {
t.storageCleanTicker = time.NewTicker(storageCleanInterval) t.storageCleanTicker = time.NewTicker(storageCleanInterval)
t.storageCleanStop = make(chan struct{}) t.storageCleanStop = make(chan struct{})
@ -385,6 +385,7 @@ func (t *TLS) keepStorageClean() {
log.Printf("[PANIC] storage cleaner: %v\n%s", err, debug.Stack()) log.Printf("[PANIC] storage cleaner: %v\n%s", err, debug.Stack())
} }
}() }()
t.cleanStorageUnits()
for { for {
select { select {
case <-t.storageCleanStop: case <-t.storageCleanStop:
@ -394,7 +395,6 @@ func (t *TLS) keepStorageClean() {
} }
} }
}() }()
t.cleanStorageUnits()
} }
func (t *TLS) cleanStorageUnits() { func (t *TLS) cleanStorageUnits() {

Loading…
Cancel
Save