mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-18 10:29:43 +00:00
make certdb maintain go routine a own func
This commit is contained in:
parent
de439f9bec
commit
a0e0d2d335
2 changed files with 64 additions and 71 deletions
|
@ -109,6 +109,9 @@ func Serve(ctx *cli.Context) error {
|
||||||
|
|
||||||
certificates.SetupCertificates(mainDomainSuffix, dnsProvider, acmeConfig, acmeUseRateLimits, enableHTTPServer, challengeCache, keyDatabase)
|
certificates.SetupCertificates(mainDomainSuffix, dnsProvider, acmeConfig, acmeUseRateLimits, enableHTTPServer, challengeCache, keyDatabase)
|
||||||
|
|
||||||
|
// TODO: make it graceful
|
||||||
|
go certificates.MaintainCertDB(mainDomainSuffix, dnsProvider, acmeUseRateLimits, keyDatabase)
|
||||||
|
|
||||||
if enableHTTPServer {
|
if enableHTTPServer {
|
||||||
go func() {
|
go func() {
|
||||||
err := httpServer.ListenAndServe("[::]:80")
|
err := httpServer.ListenAndServe("[::]:80")
|
||||||
|
|
|
@ -444,18 +444,9 @@ func SetupCertificates(mainDomainSuffix []byte, dnsProvider string, acmeConfig *
|
||||||
log.Printf("[ERROR] Couldn't renew main domain certificate, continuing with mock certs only: %s", err)
|
log.Printf("[ERROR] Couldn't renew main domain certificate, continuing with mock certs only: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
go (func() {
|
func MaintainCertDB(mainDomainSuffix []byte, dnsProvider string, acmeUseRateLimits bool, keyDatabase database.CertDB) {
|
||||||
for {
|
|
||||||
err := keyDatabase.Sync()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[ERROR] Syncing key database failed: %s", err)
|
|
||||||
}
|
|
||||||
time.Sleep(5 * time.Minute)
|
|
||||||
// TODO: graceful exit
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
go (func() {
|
|
||||||
for {
|
for {
|
||||||
// clean up expired certs
|
// clean up expired certs
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
@ -514,5 +505,4 @@ func SetupCertificates(mainDomainSuffix []byte, dnsProvider string, acmeConfig *
|
||||||
|
|
||||||
time.Sleep(12 * time.Hour)
|
time.Sleep(12 * time.Hour)
|
||||||
}
|
}
|
||||||
})()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue