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 |
+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 ./
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ require (
|
|||||||
github.com/urfave/cli v1.20.0
|
github.com/urfave/cli v1.20.0
|
||||||
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect
|
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect
|
||||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
|
||||||
golang.org/x/text v0.3.2 // indirect
|
golang.org/x/text v0.3.2 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101 // indirect
|
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101 // indirect
|
||||||
google.golang.org/grpc v1.21.0
|
google.golang.org/grpc v1.21.0
|
||||||
|
|||||||
@@ -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}}"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@@ -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