@@ -6,13 +6,68 @@ Django Tasks Scheduler
6
6
7
7
Documentation can be found in https://django-tasks-scheduler.readthedocs.io/
8
8
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
+
9
64
# Sponsor
10
65
11
66
django-tasks-scheduler is developed for free.
12
67
13
68
You can support this project by becoming a sponsor using [ this link] ( https://github.com/sponsors/cunla ) .
14
69
70
+ # Contributing
15
71
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