aboutsummaryrefslogtreecommitdiffstats
path: root/servo/management/commands/scheduler.py
diff options
context:
space:
mode:
Diffstat (limited to 'servo/management/commands/scheduler.py')
-rw-r--r--servo/management/commands/scheduler.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/servo/management/commands/scheduler.py b/servo/management/commands/scheduler.py
new file mode 100644
index 0000000..18018e5
--- /dev/null
+++ b/servo/management/commands/scheduler.py
@@ -0,0 +1,28 @@
+from datetime import datetime
+
+import django_rq
+from django.core.management.base import BaseCommand
+from django_rq.management.commands import rqscheduler
+
+
+from servo.tasks import check_mail
+
+
+scheduler = django_rq.get_scheduler('default')
+
+
+class Command(rqscheduler.Command):
+
+ help = "Start task scheduler"
+
+ def handle(self, *args, **kwargs):
+ for job in scheduler.get_jobs():
+ job.delete()
+
+ scheduler.schedule(
+ scheduled_time=datetime.utcnow(), # Time for first execution, in UTC timezone
+ func=check_mail, # Function to be queued
+ interval=300, # Time before the function is called again, in seconds
+ )
+
+ super(Command, self).handle(*args, **kwargs)