Skip to content

Commit

Permalink
升级依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
shenshuo committed Dec 23, 2018
0 parents commit 5a4c2c0
Show file tree
Hide file tree
Showing 25 changed files with 761 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

.idea
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM centos:7
# 设置编码
ENV LANG en_US.UTF-8
# 同步时间
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 1. 安装基本依赖
RUN yum update -y && yum install epel-release -y && yum update -y && yum install wget unzip epel-release nginx xz gcc automake zlib-devel openssl-devel supervisor groupinstall development libxslt-devel libxml2-devel libcurl-devel git -y
#WORKDIR /var/www/

# 2. 准备python
RUN wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
RUN xz -d Python-3.6.4.tar.xz && tar xvf Python-3.6.4.tar && cd Python-3.6.4 && ./configure && make && make install

# 3. 安装yum依赖

# 4. 复制代码
RUN mkdir -p /var/www/
ADD . /var/www/do_cron/

# 5. 安装pip依赖
RUN pip3 install --upgrade pip
RUN pip3 install -U git+https://github.com/ss1917/ops_sdk.git
RUN pip3 install -r /var/www/do_cron/doc/requirements.txt

# 6. 日志
VOLUME /var/log/

# 7. 准备文件
COPY doc/supervisor_ops.conf /etc/supervisord.conf

EXPOSE 9900
CMD ["/usr/bin/supervisord"]
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### 定时任务

> 通过定时任务可以进行添加你的定时任务


#### 1.1 定时任务特点

- restful api 简单易定制
- 可接入可视化界面操作
- 定时任务统一管理
- 完全兼容 crontab
- 支持秒级定时任务
- 任务可搜索、暂停、编辑、删除



#### 1.2 用户使用说明

- 新增任务
- job_id: 任务名称,建议为有意义的英文名称
- 可执行命令: `Linux Bash` 命令,亦可将可执行程序放入指定的目录(使用docker 切记安装依赖)
- 任务定时器: (秒、分、时、日、月、周)
- 示例:每分钟的第20秒开始执行`pwd`命令

![](./doc/images/timed_task01.png)



- 编辑任务

![](./doc/images/timed_task02.png)



- 暂停恢复
- 状态栏可以将任务暂停/恢复

![](./doc/images/timed_task03.jpg)



- 任务日志
- 每条任务执行都会记录日志
- 日志可根据Job_id、状态、关键字、时间范围等搜索

![timed_logs](./doc/images/timed_logs.jpg)

### 部署文档

> <font size="4" color="#dd0000">本服务只能启用一个进程</font>
#### 一、docker-compose 安装(推荐)

- 修改settings 配置 主要是MySQL数据库和redis 配置
- 执行 docker build . -t do_cron_image
- docker-compose up -d

#### 二、本地安装

> 建议使用虚拟环境
- 修改配置文件
- 安装依赖 pip3 install -r doc/requirements.txt
- 从doc目录获取supervisor配置文件 使用 supervisor启动 supervisorctl reload

#### 三、测试api

- 暂无

Empty file added __init__.py
Empty file.
8 changes: 8 additions & 0 deletions cron/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Contact : [email protected]
Author : shenshuo
Date : 2018/8/21
Desc :
"""
Loading

0 comments on commit 5a4c2c0

Please sign in to comment.