2017-05-26 13:59:01 +00:00
|
|
|
|
# gocron - 定时任务管理系统
|
2017-10-01 13:49:46 +00:00
|
|
|
|
[![Build Status](https://travis-ci.org/ouqiang/gocron.png)](https://travis-ci.org/ouqiang/gocron)
|
|
|
|
|
[![Downloads](https://img.shields.io/github/downloads/ouqiang/gocron/total.svg)](https://github.com/ouqiang/gocron/releases)
|
|
|
|
|
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/ouqiang/gocron/blob/master/LICENSE)
|
|
|
|
|
[![Release](https://img.shields.io/github/release/ouqiang/gocron.svg?label=Release)](https://github.com/ouqiang/gocron/releases)
|
2017-04-05 12:06:51 +00:00
|
|
|
|
|
2017-05-04 08:50:41 +00:00
|
|
|
|
# 项目简介
|
2018-05-14 14:02:27 +00:00
|
|
|
|
使用Go语言开发的轻量级定时任务集中调度和管理系统, 用于替代Linux-crontab [查看文档](https://github.com/ouqiang/gocron/wiki)
|
2017-06-29 08:44:27 +00:00
|
|
|
|
|
|
|
|
|
原有的延时任务拆分为独立项目[延迟队列](https://github.com/ouqiang/delay-queue)
|
2017-05-04 08:50:41 +00:00
|
|
|
|
|
2017-04-28 08:06:06 +00:00
|
|
|
|
## 功能特性
|
2017-10-02 03:04:21 +00:00
|
|
|
|
* Web界面管理定时任务
|
|
|
|
|
* crontab时间表达式, 精确到秒
|
|
|
|
|
* 任务执行失败可重试
|
|
|
|
|
* 任务执行超时, 强制结束
|
|
|
|
|
* 任务依赖配置, A任务完成后再执行B任务
|
|
|
|
|
* 账户权限控制
|
2017-05-28 15:13:22 +00:00
|
|
|
|
* 任务类型
|
|
|
|
|
* shell任务
|
2017-08-06 14:49:24 +00:00
|
|
|
|
> 在任务节点上执行shell命令, 支持任务同时在多个节点上运行
|
2017-05-28 15:13:22 +00:00
|
|
|
|
* HTTP任务
|
2017-07-22 01:24:50 +00:00
|
|
|
|
> 访问指定的URL地址, 由调度器直接执行, 不依赖任务节点
|
2017-10-02 03:04:21 +00:00
|
|
|
|
* 查看任务执行结果日志
|
2018-05-26 03:16:36 +00:00
|
|
|
|
* 任务执行结果通知, 支持邮件、Slack、Webhook
|
2017-04-30 23:12:39 +00:00
|
|
|
|
|
2018-05-26 03:16:36 +00:00
|
|
|
|
### 截图
|
2018-03-25 05:18:11 +00:00
|
|
|
|
![流程图](https://raw.githubusercontent.com/ouqiang/gocron/master/assets/screenshot/scheduler.png)
|
|
|
|
|
![任务](https://raw.githubusercontent.com/ouqiang/gocron/master/assets/screenshot/task.png)
|
|
|
|
|
![Slack](https://raw.githubusercontent.com/ouqiang/gocron/master/assets/screenshot/notification.png)
|
2017-04-28 08:06:06 +00:00
|
|
|
|
|
|
|
|
|
### 支持平台
|
2017-05-09 05:42:49 +00:00
|
|
|
|
> Windows、Linux、Mac OS
|
2017-04-28 08:06:06 +00:00
|
|
|
|
|
|
|
|
|
### 环境要求
|
|
|
|
|
> MySQL
|
|
|
|
|
|
|
|
|
|
|
2017-05-10 03:59:47 +00:00
|
|
|
|
## 下载
|
2017-10-01 13:49:46 +00:00
|
|
|
|
[releases](https://github.com/ouqiang/gocron/releases)
|
2017-05-26 13:59:01 +00:00
|
|
|
|
|
2017-09-06 05:12:33 +00:00
|
|
|
|
[版本升级](https://github.com/ouqiang/gocron/wiki/版本升级)
|
2017-05-10 03:59:47 +00:00
|
|
|
|
|
2017-04-28 08:06:06 +00:00
|
|
|
|
## 安装
|
2017-05-10 03:59:47 +00:00
|
|
|
|
|
2017-04-28 08:06:06 +00:00
|
|
|
|
### 二进制安装
|
2017-06-14 09:52:00 +00:00
|
|
|
|
1. 解压压缩包
|
2017-05-10 03:59:47 +00:00
|
|
|
|
2. `cd 解压目录`
|
2017-06-14 09:52:00 +00:00
|
|
|
|
3. 启动
|
2017-06-14 09:55:34 +00:00
|
|
|
|
* 调度器启动
|
|
|
|
|
* Windows: `gocron.exe web`
|
|
|
|
|
* Linux、Mac OS: `./gocron web`
|
2017-08-06 14:49:24 +00:00
|
|
|
|
* 任务节点启动, 默认监听0.0.0.0:5921
|
|
|
|
|
* Windows: `gocron-node.exe`
|
|
|
|
|
* Linux、Mac OS: `./gocron-node`
|
2017-05-10 03:59:47 +00:00
|
|
|
|
4. 浏览器访问 http://localhost:5920
|
2017-07-22 01:24:50 +00:00
|
|
|
|
|
2017-04-28 08:06:06 +00:00
|
|
|
|
### 源码安装
|
2018-05-13 15:07:44 +00:00
|
|
|
|
- 安装Go 1.9+
|
2018-05-13 14:48:37 +00:00
|
|
|
|
- `go get -d github.com/ouqiang/gocron`
|
2018-05-13 15:07:44 +00:00
|
|
|
|
- 编译 `make`
|
2018-05-13 14:48:37 +00:00
|
|
|
|
- 启动
|
2018-02-04 03:35:12 +00:00
|
|
|
|
* gocron `./bin/gocron web`
|
|
|
|
|
* gocron-node `./bin/gocron-node`
|
2017-04-28 08:06:06 +00:00
|
|
|
|
|
2018-06-19 13:09:09 +00:00
|
|
|
|
### 开发
|
|
|
|
|
|
|
|
|
|
1. 安装Go1.9+, Node.js, Yarn
|
|
|
|
|
2. 安装前端依赖 `make install-vue`
|
|
|
|
|
3. 启动gocron, gocron-node `make run`
|
|
|
|
|
4. 启动node server `cd web/vue && yarn run dev`, 访问地址 http://localhost:8080
|
|
|
|
|
|
|
|
|
|
访问http://localhost:8080, API请求会转发给gocron
|
|
|
|
|
|
|
|
|
|
`make` 编译
|
|
|
|
|
|
|
|
|
|
`make run` 编译并运行
|
|
|
|
|
|
|
|
|
|
`make package` 打包
|
|
|
|
|
> 生成当前系统的压缩包 gocron-v1.5-darwin-amd64.tar.gz gocron-node-v1.5-darwin-amd64.tar.gz
|
|
|
|
|
|
|
|
|
|
`make package-all` 生成Windows、Linux、Mac的压缩包
|
|
|
|
|
|
2017-05-20 08:26:57 +00:00
|
|
|
|
### 命令
|
2017-04-28 08:06:06 +00:00
|
|
|
|
|
2017-09-06 05:12:33 +00:00
|
|
|
|
* gocron
|
|
|
|
|
* -v 查看版本
|
|
|
|
|
|
2017-05-20 08:26:57 +00:00
|
|
|
|
* gocron web
|
2017-06-08 10:04:55 +00:00
|
|
|
|
* --host 默认0.0.0.0
|
2017-05-20 08:26:57 +00:00
|
|
|
|
* -p 端口, 指定端口, 默认5920
|
|
|
|
|
* -e 指定运行环境, dev|test|prod, dev模式下可查看更多日志信息, 默认prod
|
|
|
|
|
* -h 查看帮助
|
2017-08-06 14:49:24 +00:00
|
|
|
|
* gocron-node
|
2017-09-06 05:12:33 +00:00
|
|
|
|
* -allow-root *nix平台允许以root用户运行
|
2017-09-08 01:04:04 +00:00
|
|
|
|
* -s ip:port 监听地址
|
|
|
|
|
* -enable-tls 开启TLS
|
|
|
|
|
* -ca-file CA证书文件
|
|
|
|
|
* -cert-file 证书文件
|
2017-09-06 05:12:33 +00:00
|
|
|
|
* -key-file 私钥文件
|
|
|
|
|
* -h 查看帮助
|
|
|
|
|
* -v 查看版本
|
2017-05-07 03:38:03 +00:00
|
|
|
|
|
2017-09-03 03:25:25 +00:00
|
|
|
|
## To Do List
|
2017-09-03 13:30:03 +00:00
|
|
|
|
- [x] 版本升级
|
2017-09-05 14:31:16 +00:00
|
|
|
|
- [x] 批量开启、关闭、删除任务
|
2017-09-06 05:12:33 +00:00
|
|
|
|
- [x] 调度器与任务节点通信支持https
|
2017-09-08 01:04:04 +00:00
|
|
|
|
- [x] 任务分组
|
2017-10-01 13:49:46 +00:00
|
|
|
|
- [x] 多用户
|
2017-10-02 03:04:21 +00:00
|
|
|
|
- [x] 权限控制
|
2017-09-03 03:20:45 +00:00
|
|
|
|
|
2017-05-09 09:34:28 +00:00
|
|
|
|
## 程序使用的组件
|
2017-08-06 14:49:24 +00:00
|
|
|
|
* Web框架 [Macaron](http://go-macaron.com/)
|
2017-05-26 13:59:01 +00:00
|
|
|
|
* 定时任务调度 [Cron](https://github.com/robfig/cron)
|
2017-05-09 09:34:28 +00:00
|
|
|
|
* ORM [Xorm](https://github.com/go-xorm/xorm)
|
2018-05-13 07:42:06 +00:00
|
|
|
|
* UI框架 [Element UI](https://github.com/ElemeFE/element)
|
2018-02-04 03:35:12 +00:00
|
|
|
|
* 依赖管理 [Govendor](https://github.com/kardianos/govendor)
|
2017-05-28 15:13:22 +00:00
|
|
|
|
* RPC框架 [gRPC](https://github.com/grpc/grpc)
|
2017-05-09 09:34:28 +00:00
|
|
|
|
|
2017-05-26 10:09:07 +00:00
|
|
|
|
## 反馈
|
|
|
|
|
提交[issue](https://github.com/ouqiang/gocron/issues/new)
|
2017-08-06 14:49:24 +00:00
|
|
|
|
|
|
|
|
|
## ChangeLog
|
|
|
|
|
|
2018-05-13 07:42:06 +00:00
|
|
|
|
v1.5
|
|
|
|
|
--------
|
|
|
|
|
* 前端使用Vue+ElementUI重构
|
|
|
|
|
* 任务通知
|
|
|
|
|
* 新增WebHook通知
|
|
|
|
|
* 自定义通知模板
|
|
|
|
|
* 匹配任务执行结果关键字发送通知
|
|
|
|
|
* 任务列表页显示任务下次执行时间
|
|
|
|
|
|
2018-02-04 03:35:12 +00:00
|
|
|
|
v1.4
|
|
|
|
|
--------
|
|
|
|
|
* HTTP任务支持POST请求
|
|
|
|
|
* 后台手动停止运行中的shell任务
|
|
|
|
|
* 任务执行失败重试间隔时间支持用户自定义
|
|
|
|
|
* 修复API接口调用报403错误
|
|
|
|
|
|
2017-10-02 03:04:21 +00:00
|
|
|
|
v1.3
|
|
|
|
|
--------
|
|
|
|
|
* 支持多用户登录
|
|
|
|
|
* 增加用户权限控制
|
|
|
|
|
|
|
|
|
|
|
2017-09-08 01:04:04 +00:00
|
|
|
|
v1.2.2
|
2017-09-06 05:12:33 +00:00
|
|
|
|
--------
|
|
|
|
|
* 用户登录页增加图形验证码
|
|
|
|
|
* 支持从旧版本升级
|
|
|
|
|
* 任务批量开启、关闭、删除
|
2017-09-08 01:04:04 +00:00
|
|
|
|
* 调度器与任务节点支持HTTPS双向认证
|
2017-09-06 05:12:33 +00:00
|
|
|
|
* 修复任务列表页总记录数显示错误
|
|
|
|
|
|
2017-08-06 14:49:24 +00:00
|
|
|
|
v1.1
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
* 任务可同时在多个节点上运行
|
|
|
|
|
* *nix平台默认禁止以root用户运行任务节点
|
|
|
|
|
* 子任务命令中增加预定义占位符, 子任务可根据主任务运行结果执行相应操作
|
|
|
|
|
* 删除守护进程模块
|
|
|
|
|
* Web访问日志输出到终端
|