From a5be9ca226c4a66caaa3a80ca37711849a8c0cf8 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 13 Apr 2023 08:24:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E9=94=99=E8=AF=AF=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E9=97=AE=E9=A2=98=20(#605)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/cron/job/ssl.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/cron/job/ssl.go b/backend/cron/job/ssl.go index 044b60991..5deb05fda 100644 --- a/backend/cron/job/ssl.go +++ b/backend/cron/job/ssl.go @@ -3,7 +3,6 @@ package job import ( "github.com/1Panel-dev/1Panel/backend/app/repo" "github.com/1Panel-dev/1Panel/backend/app/service" - "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/global" "time" ) @@ -19,19 +18,22 @@ func (ssl *ssl) Run() { sslRepo := repo.NewISSLRepo() sslService := service.NewIWebsiteSSLService() sslList, _ := sslRepo.List() - global.LOG.Info("ssl renew cron job start...") + global.LOG.Info("The scheduled certificate update task is currently in progress ...") now := time.Now().Add(10 * time.Second) for _, s := range sslList { if !s.AutoRenew || s.Provider == "manual" || s.Provider == "dnsManual" { continue } - expireDate, _ := time.ParseInLocation(constant.DateTimeLayout, s.ExpireDate.String(), time.Now().Location()) - sum := expireDate.Sub(now) - if sum.Hours() < 720 { + expireDate := s.ExpireDate.In(time.Now().Location()) + sub := expireDate.Sub(now) + if sub.Hours() < 720 { + global.LOG.Errorf("Update the SSL certificate for the [%s] domain", s.PrimaryDomain) if err := sslService.Renew(s.ID); err != nil { - global.LOG.Errorf("renew doamin [%s] ssl failed err:%s", s.PrimaryDomain, err.Error()) + global.LOG.Errorf("Failed to update the SSL certificate for the [%s] domain , err:%s", s.PrimaryDomain, err.Error()) + continue } + global.LOG.Errorf("The SSL certificate for the [%s] domain has been successfully updated", s.PrimaryDomain) } } - global.LOG.Info("ssl renew cron job end...") + global.LOG.Info("The scheduled certificate update task has completed") }