Compare commits

..
6 Commits
7 changed files with 24 additions and 12 deletions
+13 -9
View File
@@ -1,18 +1,22 @@
FROM golang:1.10-alpine as builder
WORKDIR /go/src/github.com/ouqiang/gocron
COPY . .
FROM golang:1.15-alpine as builder
RUN apk update \
&& apk add --no-cache git ca-certificates make bash nodejs yarn
&& apk add --no-cache git ca-certificates make bash yarn nodejs
RUN make install-vue \
RUN go env -w GO111MODULE=on && \
go env -w GOPROXY=https://goproxy.cn,direct
WORKDIR /app
RUN git clone https://github.com/ouqiang/gocron.git \
&& cd gocron \
&& yarn config set ignore-engines true \
&& make install-vue \
&& make build-vue \
&& make statik \
&& CGO_ENABLED=0 make gocron
FROM alpine:3.7
FROM alpine:3.12
RUN apk add --no-cache ca-certificates tzdata \
&& addgroup -S app \
@@ -22,7 +26,7 @@ RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
WORKDIR /app
COPY --from=builder /go/src/github.com/ouqiang/gocron/bin/gocron .
COPY --from=builder /app/gocron/bin/gocron .
RUN chown -R app:app ./
+4 -1
View File
@@ -16,19 +16,22 @@ const slackTemplate = `
任务名称: {{.TaskName}}
状态: {{.Status}}
执行结果: {{.Result}}
备注: {{.Remark}}
`
const emailTemplate = `
任务ID: {{.TaskId}}
任务名称: {{.TaskName}}
状态: {{.Status}}
执行结果: {{.Result}}
备注: {{.Remark}}
`
const webhookTemplate = `
{
"task_id": "{{.TaskId}}",
"task_name": "{{.TaskName}}",
"status": "{{.Status}}",
"result": "{{.Result}}"
"result": "{{.Result}}",
"remark": "{{.Remark}}"
}
`
+3
View File
@@ -129,6 +129,9 @@ func (task *Task) ActiveListByHostId(hostId int16) ([]Task, error) {
if err != nil {
return nil, err
}
if len(taskIds) == 0 {
return nil, nil
}
list := make([]Task, 0)
err = Db.Where("status = ? AND level = ?", Enabled, TaskLevelParent).
In("id", taskIds...).
+1
View File
@@ -69,6 +69,7 @@ func parseNotifyTemplate(notifyTemplate string, msg Message) string {
"TaskName": msg["name"],
"Status": msg["status"],
"Result": msg["output"],
"Remark": msg["remark"],
})
return buf.String()
+1 -1
View File
@@ -251,7 +251,7 @@ func changeStatus(ctx *macaron.Context, status models.Status) string {
json := utils.JsonResponse{}
taskModel := new(models.Task)
_, err := taskModel.Update(id, models.CommonMap{
"Status": status,
"status": status,
})
if err != nil {
return json.CommonFailure(utils.FailureContent, err)
+1 -1
View File
@@ -163,7 +163,7 @@ func changeStatus(ctx *macaron.Context, status models.Status) string {
json := utils.JsonResponse{}
userModel := new(models.User)
_, err := userModel.Update(id, models.CommonMap{
"Status": status,
"status": status,
})
if err != nil {
return json.CommonFailure(utils.FailureContent, err)
+1
View File
@@ -456,6 +456,7 @@ func SendNotification(taskModel models.Task, taskResult TaskResult) {
"output": taskResult.Result,
"status": statusName,
"task_id": taskModel.Id,
"remark": taskModel.Remark,
}
notify.Push(msg)
}