Skip to content

Commit

Permalink
caddytls: Move initial storage clean op into goroutine
Browse files Browse the repository at this point in the history
Sometimes this operation can take a while (we observed 7 minutes
recently, with a large, globally-distributed storage backend).
  • Loading branch information
mholt committed Jul 8, 2020
1 parent 0bf2565 commit efc0cc5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/caddytls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ func (t *TLS) AllMatchingCertificates(san string) []certmagic.Certificate {
return t.certCache.AllMatchingCertificates(san)
}

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

func (t *TLS) cleanStorageUnits() {
Expand Down

0 comments on commit efc0cc5

Please sign in to comment.