mirror of https://github.com/ouqiang/gocron
HTTP任务执行时间不能超过300秒
parent
6f76d3b17e
commit
95ea60f23c
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
## 功能特性
|
## 功能特性
|
||||||
* 支持任务CURD
|
* 支持任务CURD
|
||||||
* crontab时间表达式,可精确到每秒
|
* crontab时间表达式,精确到秒
|
||||||
* 任务执行失败重试设置
|
* 任务执行失败重试设置
|
||||||
* 任务超时设置
|
* 任务超时设置
|
||||||
* 任务执行方式
|
* 任务执行方式
|
||||||
|
@ -21,7 +21,7 @@
|
||||||

|

|
||||||
|
|
||||||
### 支持平台
|
### 支持平台
|
||||||
> Windows、Linux、OSX
|
> Windows、Linux、Mac OS
|
||||||
|
|
||||||
### 环境要求
|
### 环境要求
|
||||||
> MySQL
|
> MySQL
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
2. `cd 解压目录`
|
2. `cd 解压目录`
|
||||||
3. 启动
|
3. 启动
|
||||||
* Windows: `gocron.exe web`
|
* Windows: `gocron.exe web`
|
||||||
* Linux、OSX: `./gocron web`
|
* Linux、Mac OS: `./gocron web`
|
||||||
4. 浏览器访问 http://localhost:5920
|
4. 浏览器访问 http://localhost:5920
|
||||||
### 源码安装
|
### 源码安装
|
||||||
1. `go`语言版本1.7+
|
1. `go`语言版本1.7+
|
||||||
|
|
|
@ -88,7 +88,7 @@ func Register(m *macaron.Macaron) {
|
||||||
|
|
||||||
// API
|
// API
|
||||||
m.Group("/api/v1", func() {
|
m.Group("/api/v1", func() {
|
||||||
m.Get("/tasklog/update-status", tasklog.UpdateStatus)
|
m.Route("/tasklog/update-status", "GET,POST", tasklog.UpdateStatus)
|
||||||
});
|
});
|
||||||
|
|
||||||
// 404错误
|
// 404错误
|
||||||
|
|
|
@ -173,7 +173,13 @@ func (h *LocalCommandHandler) runOnUnix(taskModel models.TaskHost) (string, erro
|
||||||
// HTTP任务
|
// HTTP任务
|
||||||
type HTTPHandler struct{}
|
type HTTPHandler struct{}
|
||||||
|
|
||||||
|
// http任务执行时间不超过300秒
|
||||||
|
const HttpExecTimeout = 300
|
||||||
|
|
||||||
func (h *HTTPHandler) Run(taskModel models.TaskHost) (result string, err error) {
|
func (h *HTTPHandler) Run(taskModel models.TaskHost) (result string, err error) {
|
||||||
|
if taskModel.Timeout <= 0 || taskModel.Timeout > HttpExecTimeout {
|
||||||
|
taskModel.Timeout = HttpExecTimeout
|
||||||
|
}
|
||||||
resp := httpclient.Get(taskModel.Command, taskModel.Timeout)
|
resp := httpclient.Get(taskModel.Command, taskModel.Timeout)
|
||||||
// 返回状态码非200,均为失败
|
// 返回状态码非200,均为失败
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<p>cron表达式: {{{.Spec}}}</p>
|
<p>cron表达式: {{{.Spec}}}</p>
|
||||||
<p>执行方式: {{{if eq .Protocol 1}}} HTTP {{{else if eq .Protocol 2}}} SSH {{{else if eq .Protocol 3}}}本地命令{{{end}}}</p>
|
<p>执行方式: {{{if eq .Protocol 1}}} HTTP {{{else if eq .Protocol 2}}} SSH {{{else if eq .Protocol 3}}}本地命令{{{end}}}</p>
|
||||||
<p class="sensorStatus">命令:{{{.Command}}}</p>
|
<p class="sensorStatus">命令:{{{.Command}}}</p>
|
||||||
<p class="sensorStatus">超时时间:{{{if eq .Timeout -1}}}后台运行{{{else if eq .Timeout 0}}}{{{.Timeout}}}秒{{{else}}}不限制{{{end}}}</p>
|
<p class="sensorStatus">超时时间:{{{if eq .Timeout -1}}}后台运行{{{else if gt .Timeout 0}}}{{{.Timeout}}}秒{{{else}}}不限制{{{end}}}</p>
|
||||||
<p>重试次数: {{{.RetryTimes}}}</p>
|
<p>重试次数: {{{.RetryTimes}}}</p>
|
||||||
<p class="sensorStatus">是否允许多实例运行:{{{if gt .Multi 0}}}是{{{else}}}否{{{end}}}</p>
|
<p class="sensorStatus">是否允许多实例运行:{{{if gt .Multi 0}}}是{{{else}}}否{{{end}}}</p>
|
||||||
{{{if eq .Protocol 2}}}
|
{{{if eq .Protocol 2}}}
|
||||||
|
|
Loading…
Reference in New Issue