Code Monkey home page Code Monkey logo

python-task-engine's Introduction

python-task-engine

介绍

封装的python脚本调度框架

软件架构

软件架构说明

安装教程

# 下载源码
git clone https://github.com/liuyueyi/python-task-engine.git

# 创建虚拟环境
python3.7 -m venv venv

# 安装依赖
venv/bin/pip install -r requirements.txt

使用说明

pycharm启动方式配置:

启动命令如下:

venv/bin/python3 main.py DemoCrawler -e dev -l

参数说明:

  • 第一个指定执行的python环境,当前目录下测试时,使用相对路径,crontab调度时,写绝对路径
  • main.py 为固定的程序入口,同样crontab中写绝对路径
  • DemoCrawler 需要调度的任务名,也就是具体的业务脚本的类名,要求类名与文件名一致
  • -e dev 环境指定,dev线下, pro 线上
  • -l 可以省略,表示将日志文件的内容同步打印到控制台,在测试时使用

正式上线,crontab 使用姿势

# 首先进入crontab
crontab -e

# 编写调度任务
# 每分钟执行一次 DemoCrawler.py 任务
*/1 * * * * /home/yihui/workspace/spider/venv/bin/python3.6 /home/yihui/workspace/spider/main.py DemoCrawler -e dev

通过任务启动日志判断执行状况,如没有特别指定输出的日志文件名,则任务日志文件与任务名一致,如下

less logs/DemoCrawler/DemoCrawler/DemoCrawler.log

pycharm debug测试

# DemoCrawler脚本执行case

Python 执行器
Script Path:  /Users/user/Project/GitHub/python-task-engine/main.py
Parameter: DemoCrawler -e dev -l

python-task-engine's People

Contributors

liuyueyi avatar

Stargazers

liqin avatar

Watchers

 avatar  avatar

Forkers

liqinsg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.