mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-22 08:48:43 +02:00
fix: autocert scheduler using too high cpu usage
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -169,7 +168,7 @@ func (p *Provider) ScheduleRenewal(parent task.Parent) {
|
|||||||
return
|
return
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
// Retry after 1 hour on failure
|
// Retry after 1 hour on failure
|
||||||
if time.Now().Before(lastErrOn.Add(time.Hour)) {
|
if !lastErrOn.IsZero() && time.Now().Before(lastErrOn.Add(time.Hour)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := p.renewIfNeeded(); err != nil {
|
if err := p.renewIfNeeded(); err != nil {
|
||||||
@@ -181,9 +180,6 @@ func (p *Provider) ScheduleRenewal(parent task.Parent) {
|
|||||||
lastErrOn = time.Time{}
|
lastErrOn = time.Time{}
|
||||||
renewalTime = p.ShouldRenewOn()
|
renewalTime = p.ShouldRenewOn()
|
||||||
timer.Reset(time.Until(renewalTime))
|
timer.Reset(time.Until(renewalTime))
|
||||||
default:
|
|
||||||
// Allow other tasks to run
|
|
||||||
runtime.Gosched()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
Reference in New Issue
Block a user