From 0e37ae335e4a86255a55f81a710a272f5d76f792 Mon Sep 17 00:00:00 2001 From: ouqiang Date: Mon, 24 Apr 2017 13:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 ++++++- models/task.go | 2 +- models/task_log.go | 2 +- routers/task/task.go | 2 +- templates/install/create.html | 9 +++++ templates/task/log.html | 4 +- templates/task/task_form.html | 72 +++++++++++++++++++++++++++++------ 7 files changed, 85 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index b754891..8d180b6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ -# cron-scheduler - 定时任务调度、管理 +# gocron - 定时任务web管理平台 -[![Build Status](https://travis-ci.org/ouqiang/cron-scheduler.png)](https://travis-ci.org/ouqiang/cron-scheduler) \ No newline at end of file +[![Build Status](https://travis-ci.org/ouqiang/cron-scheduler.png)](https://travis-ci.org/ouqiang/cron-scheduler) + +## 安装, 解压后执行 +```shell + ./gocron server +``` +可选参数 ++ -p 端口, 指定端口 ++ -d 后台运行 (不支持windows) ++ -h 查看帮 diff --git a/models/task.go b/models/task.go index 7c0e234..5ed54bd 100644 --- a/models/task.go +++ b/models/task.go @@ -19,7 +19,7 @@ type Task struct { Id int `xorm:"int pk autoincr"` Name string `xorm:"varchar(64) notnull"` // 任务名称 Spec string `xorm:"varchar(64) notnull"` // crontab - Protocol TaskProtocol `xorm:"tinyint notnull"` // 协议 1:http 2:ssh-command 3: 本地命令 + Protocol TaskProtocol `xorm:"tinyint notnull"` // 协议 1:http 2:ssh-command 3: 系统命令 Command string `xorm:"varchar(512) notnull"` // URL地址或shell命令 Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 RetryTimes int8 `xorm:"tinyint notnull default 0"` // 重试次数 diff --git a/models/task_log.go b/models/task_log.go index d517168..c0af3e9 100644 --- a/models/task_log.go +++ b/models/task_log.go @@ -14,7 +14,7 @@ type TaskLog struct { TaskId int `xorm:"int notnull index default 0"` // 任务id Name string `xorm:"varchar(64) notnull"` // 任务名称 Spec string `xorm:"varchar(64) notnull"` // crontab - Protocol TaskProtocol `xorm:"tinyint notnull"` // 协议 1:http 2:ssh-command + Protocol TaskProtocol `xorm:"tinyint notnull"` // 协议 1:http 2:ssh-command 3:系统命令 Command string `xorm:"varchar(512) notnull"` // URL地址或shell命令 Timeout int `xorm:"mediumint notnull default 0"` // 任务执行超时时间(单位秒),0不限制 RetryTimes int8 `xorm:"tinyint notnull default 0"` // 任务重试次数 diff --git a/routers/task/task.go b/routers/task/task.go index 84ad603..b943a4d 100644 --- a/routers/task/task.go +++ b/routers/task/task.go @@ -247,7 +247,7 @@ func parseQueryParams(ctx *macaron.Context) (models.CommonMap) { func setHostsToTemplate(ctx *macaron.Context) { hostModel := new(models.Host) hosts, err := hostModel.List(models.CommonMap{}) - if err != nil || len(hosts) == 0 { + if err != nil { logger.Error(err) } ctx.Data["Hosts"] = hosts diff --git a/templates/install/create.html b/templates/install/create.html index 1e7e4e0..2858aef 100644 --- a/templates/install/create.html +++ b/templates/install/create.html @@ -14,6 +14,10 @@
+
+

数据库配置

+
+
@@ -57,6 +61,11 @@
+
+
+

管理员账号配置

+
+
diff --git a/templates/task/log.html b/templates/task/log.html index 849ce22..8aa7b75 100644 --- a/templates/task/log.html +++ b/templates/task/log.html @@ -30,7 +30,7 @@
@@ -69,7 +69,7 @@ {{{.TaskId}}} {{{.Name}}} {{{.Spec}}} - {{{if eq .Protocol 1}}} HTTP {{{else if eq .Protocol 2}}} SSH {{{else}}} 本地命令 {{{end}}} + {{{if eq .Protocol 1}}} HTTP {{{else if eq .Protocol 2}}} SSH {{{else}}} 系统命令 {{{end}}} {{{if gt .Timeout 0}}}{{{.Timeout}}}秒{{{else}}}不限制{{{end}}} {{{.RetryTimes}}} {{{.Hostname}}} diff --git a/templates/task/task_form.html b/templates/task/task_form.html index cff7f49..93e230c 100644 --- a/templates/task/task_form.html +++ b/templates/task/task_form.html @@ -15,7 +15,9 @@
-
任务名称
+
@@ -23,51 +25,97 @@
- +
- +
-
+
+
+ 系统命令: 调用本机系统命令
+ SSH: 通过SSH执行远程命令
+ HTTP: 执行HTTP-GET请求
+
+
+
+
+
选择SSH协议时,需选择执行主机
+
+   添加主机
- + +
+ 根据选择的协议输入相应的命令
+ 系统命令 - windows: ipconfig /all linux: ifconfig -a
+ SSH - netstat -natpu
+ HTTP - http://golang.org
+
- + +
+ 默认0,不限制超时 +
+
+
- + +
+ 无法连接远程主机,shell返回值非0, http响应码非200等异常返回,可重试
+ 重试时间间隔 重试次数 * 分钟, 按1分钟、2分钟、3分钟.....的间隔进行重试
+ 取值范围1-10, 默认0,不重试 +
- + +
+ 任务添加成功后,是否立即调度 +