Skip to content

Commit

Permalink
Solve the bug that the flying book
Browse files Browse the repository at this point in the history
alarm fails
  • Loading branch information
onlyfors committed Oct 26, 2022
1 parent 06cd759 commit 376efab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions common/pkg/notify/noticer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package notify

import (
"github.com/tmnhs/crony/common/pkg/utils"
"strings"
"time"
)

Expand Down Expand Up @@ -64,4 +65,7 @@ func (m *Message) Check() {
if m.OccurTime == "" {
m.OccurTime = time.Now().Format(utils.TimeFormatSecond)
}
//Remove the transfer character
m.Body = strings.Replace(m.Body, "\"", "'", -1)
m.Body = strings.Replace(m.Body, "\n", "", -1)
}
6 changes: 3 additions & 3 deletions node/internal/handler/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (j *Job) RunWithRecovery() {
Type: j.NotifyType,
IP: fmt.Sprintf("%s:%s", node.IP, node.PID),
Subject: fmt.Sprintf("任务[%s]立即执行失败", j.Name),
Body: strings.Replace(fmt.Sprintf("job[%d] run on node[%s] once execute failed ,output:%s,error:%s", j.ID, j.RunOn, result, runErr.Error()), "\n", "", -1),
Body: fmt.Sprintf("job[%d] run on node[%s] once execute failed ,output:%s,error:%s", j.ID, j.RunOn, result, runErr.Error()),
To: to,
OccurTime: time.Now().Format(utils.TimeFormatSecond),
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func CreateJob(j *Job) cron.FuncJob {
}
i++
if i < execTimes {
logger.GetLogger().Warn(fmt.Sprintf("job execution failure#jobId-%d#retry%d次#output-%s#error-%v", j.ID, i, output, runErr))
logger.GetLogger().Warn(fmt.Sprintf("job execution failure#jobId-%d#retry %d times #output-%s#error-%v", j.ID, i, output, runErr))
if j.RetryInterval > 0 {
time.Sleep(time.Duration(j.RetryInterval) * time.Second)
} else {
Expand Down Expand Up @@ -202,7 +202,7 @@ func CreateJob(j *Job) cron.FuncJob {
Type: j.NotifyType,
IP: fmt.Sprintf("%s:%s", node.IP, node.PID),
Subject: fmt.Sprintf("任务[%s]执行失败", j.Name),
Body: strings.Replace(fmt.Sprintf("job[%d] run on node[%s] execute failed ,retry %d times ,output :%s, error:%v", j.ID, j.RunOn, j.RetryTimes, output, runErr), "\n", "", -1),
Body: fmt.Sprintf("job[%d] run on node[%s] execute failed ,retry %d times ,output :%s, error:%v", j.ID, j.RunOn, j.RetryTimes, output, runErr),
To: to,
OccurTime: time.Now().Format(utils.TimeFormatSecond),
}
Expand Down

0 comments on commit 376efab

Please sign in to comment.