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
|
FROM golang:1.15-alpine as builder
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/ouqiang/gocron
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN apk update \
|
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 build-vue \
|
||||||
&& make statik \
|
&& make statik \
|
||||||
&& CGO_ENABLED=0 make gocron
|
&& CGO_ENABLED=0 make gocron
|
||||||
|
|
||||||
FROM alpine:3.7
|
FROM alpine:3.12
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates tzdata \
|
RUN apk add --no-cache ca-certificates tzdata \
|
||||||
&& addgroup -S app \
|
&& addgroup -S app \
|
||||||
@@ -22,7 +26,7 @@ RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
|||||||
|
|
||||||
WORKDIR /app
|
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 ./
|
RUN chown -R app:app ./
|
||||||
|
|
||||||
|
|||||||
@@ -16,19 +16,22 @@ const slackTemplate = `
|
|||||||
任务名称: {{.TaskName}}
|
任务名称: {{.TaskName}}
|
||||||
状态: {{.Status}}
|
状态: {{.Status}}
|
||||||
执行结果: {{.Result}}
|
执行结果: {{.Result}}
|
||||||
|
备注: {{.Remark}}
|
||||||
`
|
`
|
||||||
const emailTemplate = `
|
const emailTemplate = `
|
||||||
任务ID: {{.TaskId}}
|
任务ID: {{.TaskId}}
|
||||||
任务名称: {{.TaskName}}
|
任务名称: {{.TaskName}}
|
||||||
状态: {{.Status}}
|
状态: {{.Status}}
|
||||||
执行结果: {{.Result}}
|
执行结果: {{.Result}}
|
||||||
|
备注: {{.Remark}}
|
||||||
`
|
`
|
||||||
const webhookTemplate = `
|
const webhookTemplate = `
|
||||||
{
|
{
|
||||||
"task_id": "{{.TaskId}}",
|
"task_id": "{{.TaskId}}",
|
||||||
"task_name": "{{.TaskName}}",
|
"task_name": "{{.TaskName}}",
|
||||||
"status": "{{.Status}}",
|
"status": "{{.Status}}",
|
||||||
"result": "{{.Result}}"
|
"result": "{{.Result}}",
|
||||||
|
"remark": "{{.Remark}}"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ func (task *Task) ActiveListByHostId(hostId int16) ([]Task, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if len(taskIds) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
list := make([]Task, 0)
|
list := make([]Task, 0)
|
||||||
err = Db.Where("status = ? AND level = ?", Enabled, TaskLevelParent).
|
err = Db.Where("status = ? AND level = ?", Enabled, TaskLevelParent).
|
||||||
In("id", taskIds...).
|
In("id", taskIds...).
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ func parseNotifyTemplate(notifyTemplate string, msg Message) string {
|
|||||||
"TaskName": msg["name"],
|
"TaskName": msg["name"],
|
||||||
"Status": msg["status"],
|
"Status": msg["status"],
|
||||||
"Result": msg["output"],
|
"Result": msg["output"],
|
||||||
|
"Remark": msg["remark"],
|
||||||
})
|
})
|
||||||
|
|
||||||
return buf.String()
|
return buf.String()
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ func changeStatus(ctx *macaron.Context, status models.Status) string {
|
|||||||
json := utils.JsonResponse{}
|
json := utils.JsonResponse{}
|
||||||
taskModel := new(models.Task)
|
taskModel := new(models.Task)
|
||||||
_, err := taskModel.Update(id, models.CommonMap{
|
_, err := taskModel.Update(id, models.CommonMap{
|
||||||
"Status": status,
|
"status": status,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return json.CommonFailure(utils.FailureContent, err)
|
return json.CommonFailure(utils.FailureContent, err)
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ func changeStatus(ctx *macaron.Context, status models.Status) string {
|
|||||||
json := utils.JsonResponse{}
|
json := utils.JsonResponse{}
|
||||||
userModel := new(models.User)
|
userModel := new(models.User)
|
||||||
_, err := userModel.Update(id, models.CommonMap{
|
_, err := userModel.Update(id, models.CommonMap{
|
||||||
"Status": status,
|
"status": status,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return json.CommonFailure(utils.FailureContent, err)
|
return json.CommonFailure(utils.FailureContent, err)
|
||||||
|
|||||||
@@ -456,6 +456,7 @@ func SendNotification(taskModel models.Task, taskResult TaskResult) {
|
|||||||
"output": taskResult.Result,
|
"output": taskResult.Result,
|
||||||
"status": statusName,
|
"status": statusName,
|
||||||
"task_id": taskModel.Id,
|
"task_id": taskModel.Id,
|
||||||
|
"remark": taskModel.Remark,
|
||||||
}
|
}
|
||||||
notify.Push(msg)
|
notify.Push(msg)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user