mirror of https://github.com/ouqiang/gocron
删除延时任务
parent
2082109386
commit
d5eed97595
|
@ -6,17 +6,11 @@ import (
|
|||
|
||||
type TaskType int8
|
||||
|
||||
const (
|
||||
Timing = iota + 1 // 定时任务
|
||||
Delay // 延时任务
|
||||
)
|
||||
|
||||
// 任务执行日志
|
||||
type TaskLog struct {
|
||||
Id int64 `xorm:"bigint pk autoincr"`
|
||||
TaskId int `xorm:"int notnull index default 0"` // 任务id
|
||||
Type TaskType `xorm:"tinyint notnull default 1"` // 任务类型 1 定时任务 2 延时任务
|
||||
Delay int `xorm:"int notnull default 0"` // 延时任务-延时时间
|
||||
Name string `xorm:"varchar(64) notnull"` // 任务名称
|
||||
Spec string `xorm:"varchar(64) notnull"` // crontab
|
||||
Protocol TaskProtocol `xorm:"tinyint notnull"` // 协议 1:http 2:ssh-command
|
||||
|
@ -25,7 +19,7 @@ type TaskLog struct {
|
|||
Hostname string `xorm:"varchar(512) notnull defalut '' "` // SSH主机名,逗号分隔
|
||||
StartTime time.Time `xorm:"datetime created"` // 开始执行时间
|
||||
EndTime time.Time `xorm:"datetime updated"` // 执行完成(失败)时间
|
||||
Status Status `xorm:"tinyint notnull default 1"` // 状态 1:执行中 2:执行完毕 0:执行失败 -1 待执行
|
||||
Status Status `xorm:"tinyint notnull default 1"` // 状态 1:执行中 2:执行完毕 0:执行失败
|
||||
Result string `xorm:"varchar(65535) notnull defalut '' "` // 执行结果
|
||||
Page int `xorm:"-"`
|
||||
PageSize int `xorm:"-"`
|
||||
|
|
|
@ -93,16 +93,16 @@ func writef(level Level, format string, v... interface{}) {
|
|||
|
||||
switch level {
|
||||
case DEBUG:
|
||||
logger.Debugf(v)
|
||||
logger.Debugf(format, v)
|
||||
case INFO:
|
||||
logger.Infof(v)
|
||||
logger.Infof(format, v)
|
||||
case WARN:
|
||||
logger.Warnf(v)
|
||||
logger.Warnf(format, v)
|
||||
case FATAL:
|
||||
logger.Criticalf(v)
|
||||
logger.Criticalf(format, v)
|
||||
os.Exit(1)
|
||||
case ERROR:
|
||||
logger.Errorf(v)
|
||||
logger.Errorf(format, v)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package delaytask
|
||||
|
||||
import (
|
||||
"gopkg.in/macaron.v1"
|
||||
"github.com/ouqiang/gocron/models"
|
||||
)
|
||||
|
||||
type DelayForm struct {
|
||||
Protocol models.TaskType
|
||||
Type models.TaskType
|
||||
Host string
|
||||
Delay int
|
||||
Command string
|
||||
Timeout int
|
||||
}
|
||||
|
||||
// 创建延时任务
|
||||
func Create(ctx *macaron.Context) {
|
||||
|
||||
}
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/go-macaron/gzip"
|
||||
"strings"
|
||||
"github.com/ouqiang/gocron/modules/app"
|
||||
"github.com/ouqiang/gocron/routers/api/v1/delaytask"
|
||||
)
|
||||
|
||||
// 静态文件目录
|
||||
|
@ -76,12 +75,6 @@ func Register(m *macaron.Macaron) {
|
|||
m.Get("", host.Index)
|
||||
m.Post("/remove/:id", host.Remove)
|
||||
})
|
||||
|
||||
// API接口
|
||||
m.Group("/api/v1", func() {
|
||||
// 添加延时任务
|
||||
m.Post("/task/delay", delaytask.Create)
|
||||
})
|
||||
}
|
||||
|
||||
// 中间件注册
|
||||
|
|
|
@ -106,7 +106,6 @@ func (h *SSHCommandHandler) Run(taskModel models.TaskHost) (string, error) {
|
|||
func createTaskLog(taskModel models.TaskHost) (int64, error) {
|
||||
taskLogModel := new(models.TaskLog)
|
||||
taskLogModel.TaskId = taskModel.Id
|
||||
taskLogModel.Type = models.Timing
|
||||
taskLogModel.Name = taskModel.Task.Name
|
||||
taskLogModel.Spec = taskModel.Spec
|
||||
taskLogModel.Protocol = taskModel.Protocol
|
||||
|
|
|
@ -27,11 +27,9 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>任务名称</th>
|
||||
<th>任务类型</th>
|
||||
<th>cron表达式</th>
|
||||
<th>协议</th>
|
||||
<th>超时时间(秒)</th>
|
||||
<th>延时时间(秒)</th>
|
||||
<th>主机</th>
|
||||
<th>开始时间</th>
|
||||
<th>结束时间</th>
|
||||
|
@ -43,17 +41,15 @@
|
|||
{{{range $i, $v := .Logs}}}
|
||||
<tr>
|
||||
<td>{{{.Name}}}</td>
|
||||
<td>{{{if eq .Type 1}}}定时任务{{{else}}}延时任务{{{end}}}</td>
|
||||
<td>{{{.Spec}}}</td>
|
||||
<td>{{{if eq .Protocol 1}}} HTTP {{{else}}} SSH {{{end}}}</td>
|
||||
<td>{{{.Timeout}}}</td>
|
||||
<td>{{{.Delay}}}</td>
|
||||
<td>{{{.Hostname}}}</td>
|
||||
<td>
|
||||
{{{.StartTime.Format "2006-01-02 15:03:04" }}}
|
||||
{{{.StartTime.Format "2006-01-02 15:04:05" }}}
|
||||
</td>
|
||||
<td>
|
||||
{{{.EndTime.Format "2006-01-02 15:03:04" }}}
|
||||
{{{.EndTime.Format "2006-01-02 15:04:05" }}}
|
||||
</td>
|
||||
<td>
|
||||
{{{if eq .Status 2}}}
|
||||
|
|
Loading…
Reference in New Issue