mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-16 18:54:43 +08:00
fix: 时区问题修改 (#855)
This commit is contained in:
parent
c62fd4841a
commit
c679631440
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,8 +78,9 @@ func (b *BaseApi) SearchJobRecords(c *gin.Context) {
|
|||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.StartTime = req.StartTime.Add(8 * time.Hour)
|
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
||||||
req.EndTime = req.EndTime.Add(8 * time.Hour)
|
req.StartTime = req.StartTime.In(loc)
|
||||||
|
req.EndTime = req.EndTime.In(loc)
|
||||||
|
|
||||||
total, list, err := cronjobService.SearchRecords(req)
|
total, list, err := cronjobService.SearchRecords(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/shirou/gopsutil/v3/disk"
|
"github.com/shirou/gopsutil/v3/disk"
|
||||||
"github.com/shirou/gopsutil/v3/net"
|
"github.com/shirou/gopsutil/v3/net"
|
||||||
@ -24,8 +25,9 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
|||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.StartTime = req.StartTime.Add(8 * time.Hour)
|
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
||||||
req.EndTime = req.EndTime.Add(8 * time.Hour)
|
req.StartTime = req.StartTime.In(loc)
|
||||||
|
req.EndTime = req.EndTime.In(loc)
|
||||||
|
|
||||||
var backdatas []dto.MonitorData
|
var backdatas []dto.MonitorData
|
||||||
if req.Param == "all" || req.Param == "cpu" || req.Param == "memory" || req.Param == "load" {
|
if req.Param == "all" || req.Param == "cpu" || req.Param == "memory" || req.Param == "load" {
|
||||||
|
@ -9,22 +9,20 @@ import (
|
|||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/cron/job"
|
"github.com/1Panel-dev/1Panel/backend/cron/job"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
nyc, _ := time.LoadLocation("Asia/Shanghai")
|
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
||||||
Cron := cron.New(cron.WithLocation(nyc), cron.WithChain(cron.Recover(cron.DefaultLogger)), cron.WithChain(cron.DelayIfStillRunning(cron.DefaultLogger)))
|
Cron := cron.New(cron.WithLocation(nyc), cron.WithChain(cron.Recover(cron.DefaultLogger)), cron.WithChain(cron.DelayIfStillRunning(cron.DefaultLogger)))
|
||||||
_, err := Cron.AddJob("@every 5m", job.NewMonitorJob())
|
if _, err := Cron.AddJob("@every 5m", job.NewMonitorJob()); err != nil {
|
||||||
if err != nil {
|
|
||||||
global.LOG.Errorf("can not add monitor corn job: %s", err.Error())
|
global.LOG.Errorf("can not add monitor corn job: %s", err.Error())
|
||||||
}
|
}
|
||||||
_, err = Cron.AddJob("@daily", job.NewWebsiteJob())
|
if _, err := Cron.AddJob("@daily", job.NewWebsiteJob()); err != nil {
|
||||||
if err != nil {
|
|
||||||
global.LOG.Errorf("can not add website corn job: %s", err.Error())
|
global.LOG.Errorf("can not add website corn job: %s", err.Error())
|
||||||
}
|
}
|
||||||
_, err = Cron.AddJob("@daily", job.NewSSLJob())
|
if _, err := Cron.AddJob("@daily", job.NewSSLJob()); err != nil {
|
||||||
if err != nil {
|
|
||||||
global.LOG.Errorf("can not add ssl corn job: %s", err.Error())
|
global.LOG.Errorf("can not add ssl corn job: %s", err.Error())
|
||||||
}
|
}
|
||||||
Cron.Start()
|
Cron.Start()
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ func PasswordExpired() gin.HandlerFunc {
|
|||||||
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loc, _ := time.LoadLocation("Asia/Shanghai")
|
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
||||||
expiredTime, err := time.ParseInLocation("2006-01-02 15:04:05", extime.Value, loc)
|
expiredTime, err := time.ParseInLocation("2006-01-02 15:04:05", extime.Value, loc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CompareVersion(version1 string, version2 string) bool {
|
func CompareVersion(version1 string, version2 string) bool {
|
||||||
@ -134,3 +135,11 @@ func LoadSizeUnit(value float64) string {
|
|||||||
}
|
}
|
||||||
return fmt.Sprintf("%v", value)
|
return fmt.Sprintf("%v", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadTimeZone() string {
|
||||||
|
loc := time.Now().Location()
|
||||||
|
if _, err := time.LoadLocation(loc.String()); err != nil {
|
||||||
|
return "Asia/Shanghai"
|
||||||
|
}
|
||||||
|
return loc.String()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user