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