mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-09 07:54:03 +02:00
fix: autocert scheduler using too high cpu usage
This commit is contained in:
parent
fc29e8f9fa
commit
2bb13129de
1 changed files with 1 additions and 5 deletions
|
@ -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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Add table
Reference in a new issue