🔥 移除后台登录类型设置,增加调度失败计划任务提醒

This commit is contained in:
naiba
2021-09-30 00:01:04 +08:00
parent 8af9b1ab18
commit 092f40b47f
8 changed files with 22 additions and 20 deletions

View File

@@ -30,11 +30,6 @@ type NotificationHistory struct {
func AlertSentinelStart() {
alertsStore = make(map[uint64]map[uint64][][]interface{})
alertsPrevState = make(map[uint64]map[uint64]uint)
notificationsLock.Lock()
if err := DB.Find(&notifications).Error; err != nil {
panic(err)
}
notificationsLock.Unlock()
alertsLock.Lock()
if err := DB.Find(&alerts).Error; err != nil {
panic(err)

View File

@@ -13,7 +13,7 @@ import (
pb "github.com/naiba/nezha/proto"
)
var Version = "v0.10.2" // !!记得修改 README 中的 badge 版本!!
var Version = "v0.10.3" // !!记得修改 README 中的 badge 版本!!
var (
Conf *model.Config

View File

@@ -16,6 +16,14 @@ const firstNotificationDelay = time.Minute * 15
var notifications []model.Notification
var notificationsLock sync.RWMutex
func LoadNotifications() {
notificationsLock.Lock()
if err := DB.Find(&notifications).Error; err != nil {
panic(err)
}
notificationsLock.Unlock()
}
func OnRefreshOrAddNotification(n model.Notification) {
notificationsLock.Lock()
defer notificationsLock.Unlock()

View File

@@ -146,7 +146,6 @@ func (ss *ServiceSentinel) loadMonitorHistory() {
monitors[i].CronJobID, err = Cron.AddFunc(task.CronSpec(), func() {
ss.dispatchBus <- task
})
log.Println("NEZHA>> 服务监控任务", monitors[i].ID, monitors[i].Name, monitors[i].CronJobID)
if err != nil {
panic(err)
}