Skip to content
/ cronjob Public
forked from havefun-plus/cronjob

a simple distributed `cron job` framework

License

Notifications You must be signed in to change notification settings

ZmN5/cronjob

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cronjob


Overview

cronjob是一个轻量、分布式、异步的定时任务框架,主要参考scrapyrq,异步主要基于gevent。所有的定时任务都会在gevent的微线程中执行。


Installation

pip install cronjob

pip install git+https://github.com/havefun-plus/cronjob.git


Usage

1. settings

通过环境变量CRONJOB_SETTINGS指定配置文件, 配置见settings.example.py

  • 通过CRONJOBS_MODULE = 'cronjobs'指定定时任务所在路径
  • 通过QUEUE_CONFIG = dict(queue_type='thread', config=None)指定使用在什么模式运行
    • 指定redis,同时要指定redis配置
    • 指定thread,只能在单节点运行

参考: https://github.com/havefun-plus/ip-proxy-pool/blob/master/ipfeeder/settings.py

2. 创建定时任务

参考:

3. 执行

单节点运行:

  • cronjob run 默认一个线程调度任务,一个线程爬取
  • cronjob run --mode thread --num 2 启动两个线程执行

多节点运行:

注意只能增加worker实例,master实例只能为1

参考:


项目参考:

eat your own dog food

基于cronjob实现的项目:

IP代理池

About

a simple distributed `cron job` framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.9%
  • Makefile 1.1%