• This repository has been archived on 25/Aug/2024
  • Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Celery Beat Scheduler that uses MongoDB to store both schedule definitions and status information

celerybeat-mongo

This is a Celery Beat Scheduler that stores both the schedules themselves and their status information in a backend Mongo database. It can be installed by installing the celerybeat-mongo Python egg:

# pip install celerybeat-mongo

And specifying the scheduler when running Celery Beat, e.g.:

$ celery beat -S celerybeatmongo.schedulers.MongoScheduler

Settings

The settings for the scheduler are defined in your celery configuration file similar to how other aspects of Celery are configured:

  • mongodb_scheduler_url: The mongodb url connection used to store task results.
  • mongodb_scheduler_db: The Mongodb database name
  • mongodb_scheduler_collection (optional): the collection name used by model. If no value are specified, the default value will be used: schedules.

Usage

Celerybeat-mongo just supports Interval and Crontab schedules. Schedules easily can be manipulated using the mongoengine models in celerybeat mongo.models module.

Example creating interval-based periodic task

To create a periodic task executing at an interval you must first create the interval object:

from celery import Celery

config = {
    "mongodb_scheduler_db": "my_project",
    "mongodb_scheduler_url": "mongodb://localhost:27017",
}

app = Celery('hello', broker='redis://localhost//')
app.conf.update(**config)

from celerybeatmongo.models import PeriodicTask

periodic = PeriodicTask(
    name='Importing contacts',
    task="proj.import_contacts"
    interval=PeriodicTask.Interval(every=10, period="seconds") # executes every 10 seconds.
)
periodic.save()

Note

You should import celerybeat-mongo just after celery initialization.

Example creating crontab periodic task

A crontab schedule has the fields: minute, hour, day_of_week, day_of_month and month_of_year, so if you want the equivalent of a 30 7 * * 1 (Executes every Monday morning at 7:30 a.m) crontab entry you specify:

from celery import Celery

config = {
    "mongodb_scheduler_db": "my_project",
    "mongodb_scheduler_url": "mongodb://localhost:27017",
}

app = Celery('hello', broker='redis://localhost//')
app.conf.update(**config)

from celerybeatmongo.models import PeriodicTask

periodic = PeriodicTask(name="Send Email Notification", task="proj.notify_customers")
periodic.crontab = PeriodicTask.Crontab(minute="30", hour="7", day_of_week="1",
                           day_of_month="0", month_of_year="*")
periodic.save()

More Repositories

1

zmap

ZMap is a fast single packet network scanner designed for Internet-wide network surveys.
C
5,453
star
2

zgrab2

Fast Go Application Scanner
Go
1,726
star
3

zdns

Fast DNS Lookup Library and CLI Tool
Go
920
star
4

zgrab

**DEPRECATED** This project has been replaced by https://github.com/zmap/zgrab2
Go
748
star
5

zlint

X.509 Certificate Linter focused on Web PKI standards and requirements.
Go
356
star
6

zcrypto

Liberal Go TLS + X.509 Library for Research
Go
134
star
7

go-iptree

GoLang IP Radix Tree
Go
113
star
8

ztag

Tagging and annotation framework for scan data
Python
101
star
9

zannotate

Utility for annotating Internet datasets with contextual metadata (e.g., origin AS, MaxMind GeoIP2, reverse DNS, and WHOIS)
Go
94
star
10

zbrowse

Headless Chrome-based browser
JavaScript
60
star
11

zcertificate

Command line utility for parsing certificates
Go
59
star
12

zschema

A schema language for JSON documents that allows validation and compilation into various database engines
Python
40
star
13

pybulkwhois

Python framework for manipulating bulk WHOIS data from RIRs
Python
19
star
14

iptree

A space-optimized binary tree for storing IP addresses
C++
13
star
15

constants

Repository of constants used in TLS and X509 parsing
12
star
16

rootfetch

Python egg for fetching common certificate root stores
Python
9
star
17

cachehash

An efficient C hash-table like data structure with static size that evicts LRU object on insertion
C
9
star
18

zson

A python library that allows easily encoding and decoding objects into JSON
Python
7
star
19

zflags

go command line option parser http://godoc.org/github.com/jessevdk/โ€ฆ
Go
6
star
20

website

ZMap's Public Website
HTML
5
star
21

zdb

[deprecated] Backend database for Internet-wide scans
C++
4
star
22

zlint-test-corpus

Test certificates for ZLint CI tests
2
star
23

homebrew-formula

Dependencies not included in standard Homebrew taps
Ruby
1
star