mirror of
https://github.com/ouqiang/gocron.git
synced 2024-04-21 12:31:58 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
960fc988b1 | ||
|
|
7a949a22bf | ||
|
|
c59f8b730a | ||
|
|
ac2f01f144 | ||
|
|
09834ffaf6 | ||
|
|
93c544f0d4 |
+13
-9
@@ -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 ./
|
||||
|
||||
|
||||
@@ -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}}"
|
||||
}
|
||||
`
|
||||
|
||||
|
||||
@@ -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...).
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user