@@ -6,13 +6,68 @@ Django Tasks Scheduler
66
77Documentation can be found in https://django-tasks-scheduler.readthedocs.io/
88
9+ # Usage
10+
11+ 1 . Update ` settings.py ` to include scheduler configuration:
12+
13+ ``` python
14+ import os
15+ from typing import Dict
16+ from scheduler.types import SchedulerConfiguration, Broker, QueueConfiguration
17+
18+ INSTALLED_APPS = [
19+ # ...
20+ ' scheduler' ,
21+ # ...
22+ ]
23+ SCHEDULER_CONFIG = SchedulerConfiguration(
24+ EXECUTIONS_IN_PAGE = 20 ,
25+ SCHEDULER_INTERVAL = 10 ,
26+ BROKER = Broker.REDIS ,
27+ CALLBACK_TIMEOUT = 60 , # Callback timeout in seconds (success/failure/stopped)
28+ # Default values, can be overriden per task/job
29+ DEFAULT_SUCCESS_TTL = 10 * 60 , # Time To Live (TTL) in seconds to keep successful job results
30+ DEFAULT_FAILURE_TTL = 365 * 24 * 60 * 60 , # Time To Live (TTL) in seconds to keep job failure information
31+ DEFAULT_JOB_TTL = 10 * 60 , # Time To Live (TTL) in seconds to keep job information
32+ DEFAULT_JOB_TIMEOUT = 5 * 60 , # timeout (seconds) for a job
33+ # General configuration values
34+ DEFAULT_WORKER_TTL = 10 * 60 , # Time To Live (TTL) in seconds to keep worker information after last heartbeat
35+ DEFAULT_MAINTENANCE_TASK_INTERVAL = 10 * 60 , # The interval to run maintenance tasks in seconds. 10 minutes.
36+ DEFAULT_JOB_MONITORING_INTERVAL = 30 , # The interval to monitor jobs in seconds.
37+ SCHEDULER_FALLBACK_PERIOD_SECS = 120 , # Period (secs) to wait before requiring to reacquire locks
38+ )
39+ SCHEDULER_QUEUES : Dict[str , QueueConfiguration] = {
40+ ' default' : QueueConfiguration(URL = ' redis://localhost:6379/0' ),
41+ }
42+ ```
43+
44+ 2 . Update ` urls.py ` to include scheduler urls:
45+
46+ ``` python
47+ from django.urls import path, include
48+
49+ urlpatterns = [
50+ # ...
51+ path(' scheduler/' , include(' scheduler.urls' )),
52+ ]
53+ ```
54+
55+ 3 . Run migrations:
56+
57+ ``` bash
58+ python manage.py migrate
59+ ```
60+
61+ 4 . Check out the admin views:
62+ ![ ] ( ./docs/media/admin-tasks-list.jpg )
63+
964# Sponsor
1065
1166django-tasks-scheduler is developed for free.
1267
1368You can support this project by becoming a sponsor using [ this link] ( https://github.com/sponsors/cunla ) .
1469
70+ # Contributing
1571
16- # Contributing
17-
18- Interested in contributing, providing suggestions, or submitting bugs? See guidelines [ at this link] ( .github/CONTRIBUTING.md ) .
72+ Interested in contributing, providing suggestions, or submitting bugs? See
73+ guidelines [ at this link] ( .github/CONTRIBUTING.md ) .
0 commit comments