mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
🐛 修改计划任务并未取消旧任务
This commit is contained in:
parent
092f40b47f
commit
a25a1b128d
@ -4,7 +4,7 @@
|
||||
<br>
|
||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||
<br><br>
|
||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.10.3&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.7.0-brightgreen?style=for-the-badge&logo=linux">
|
||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.10.4&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.7.0-brightgreen?style=for-the-badge&logo=linux">
|
||||
<br>
|
||||
<br>
|
||||
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/robfig/cron/v3"
|
||||
|
||||
"github.com/naiba/nezha/model"
|
||||
"github.com/naiba/nezha/pkg/mygin"
|
||||
@ -82,8 +81,8 @@ func (ma *memberAPI) delete(c *gin.Context) {
|
||||
dao.CronLock.RLock()
|
||||
defer dao.CronLock.RUnlock()
|
||||
cr := dao.Crons[id]
|
||||
if cr != nil && cr.CronID != 0 {
|
||||
dao.Cron.Remove(cr.CronID)
|
||||
if cr != nil && cr.CronJobID != 0 {
|
||||
dao.Cron.Remove(cr.CronJobID)
|
||||
}
|
||||
delete(dao.Crons, id)
|
||||
}
|
||||
@ -276,7 +275,7 @@ func (ma *memberAPI) addOrEditCron(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
cr.CronID, err = dao.Cron.AddFunc(cr.Scheduler, dao.CronTrigger(cr))
|
||||
cr.CronJobID, err = dao.Cron.AddFunc(cr.Scheduler, dao.CronTrigger(cr))
|
||||
}
|
||||
if err == nil {
|
||||
err = tx.Commit().Error
|
||||
@ -294,8 +293,8 @@ func (ma *memberAPI) addOrEditCron(c *gin.Context) {
|
||||
dao.CronLock.Lock()
|
||||
defer dao.CronLock.Unlock()
|
||||
crOld := dao.Crons[cr.ID]
|
||||
if crOld != nil && crOld.CronID != 0 {
|
||||
dao.Cron.Remove(cron.EntryID(crOld.ID))
|
||||
if crOld != nil && crOld.CronJobID != 0 {
|
||||
dao.Cron.Remove(crOld.CronJobID)
|
||||
}
|
||||
|
||||
delete(dao.Crons, cr.ID)
|
||||
|
@ -165,7 +165,7 @@ func loadCrons() {
|
||||
crIgnoreMap[cr.Servers[j]] = true
|
||||
}
|
||||
|
||||
cr.CronID, err = dao.Cron.AddFunc(cr.Scheduler, dao.CronTrigger(cr))
|
||||
cr.CronJobID, err = dao.Cron.AddFunc(cr.Scheduler, dao.CronTrigger(cr))
|
||||
if err == nil {
|
||||
dao.Crons[cr.ID] = &cr
|
||||
} else {
|
||||
|
@ -24,7 +24,7 @@ type Cron struct {
|
||||
LastResult bool // 最后一次执行结果
|
||||
Cover uint8
|
||||
|
||||
CronID cron.EntryID `gorn:"-"`
|
||||
CronJobID cron.EntryID `gorn:"-"`
|
||||
ServersRaw string
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
pb "github.com/naiba/nezha/proto"
|
||||
)
|
||||
|
||||
var Version = "v0.10.3" // !!记得修改 README 中的 badge 版本!!
|
||||
var Version = "v0.10.4" // !!记得修改 README 中的 badge 版本!!
|
||||
|
||||
var (
|
||||
Conf *model.Config
|
||||
|
Loading…
Reference in New Issue
Block a user