mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
New jobs for amavis and calendars apps.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
"""Async jobs definition."""
|
||||
|
||||
from django.core.management import call_command
|
||||
|
||||
|
||||
def amnotify():
|
||||
call_command("amnotify")
|
||||
|
||||
|
||||
def qcleanup():
|
||||
call_command("qcleanup")
|
||||
@@ -0,0 +1,7 @@
|
||||
"""Async jobs definition."""
|
||||
|
||||
from django.core.management import call_command
|
||||
|
||||
|
||||
def generate_rights():
|
||||
call_command("generate_rights")
|
||||
@@ -3,6 +3,8 @@
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from django.core.management import call_command
|
||||
|
||||
from modoboa.core.models import Log
|
||||
from modoboa.maillog.models import Maillog
|
||||
from modoboa.parameters import tools as param_tools
|
||||
@@ -26,3 +28,7 @@ def clean_logs():
|
||||
)
|
||||
limit = timezone.now() - datetime.timedelta(message_history_maximum_age)
|
||||
Maillog.objects.filter(date__lt=limit).delete()
|
||||
|
||||
|
||||
def communicate_with_public_api():
|
||||
call_command("communicate_with_public_api")
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import timezone
|
||||
|
||||
from modoboa.core.models import Log
|
||||
from modoboa.parameters import tools as param_tools
|
||||
|
||||
JOB_IDs = ["clearsessions_r", "cleanlogs_r", "logparser_r"]
|
||||
AMAVIS_IDs = ["qcleanup_r", "amnotify_r"]
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Command class."""
|
||||
|
||||
help = "Checks that redondants jobs are started or start them" # NOQA:A003
|
||||
|
||||
def add_arguments(self, parser):
|
||||
"""Add extra arguments to command line."""
|
||||
parser.add_argument(
|
||||
"--queue-now",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Queue all redondant job now",
|
||||
)
|
||||
|
||||
def check_clean_log(queue_now=False):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.check_clean_log(options["queue_now"])
|
||||
@@ -1,5 +1,11 @@
|
||||
import random
|
||||
|
||||
from rq.cron import register
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from modoboa.amavis import jobs as amavis_jobs
|
||||
from modoboa.calendars import jobs as calendars_jobs
|
||||
from modoboa.core import jobs as core_jobs
|
||||
from modoboa.admin import jobs as admin_jobs
|
||||
from modoboa.maillog import jobs as maillog_jobs
|
||||
@@ -7,7 +13,22 @@ from modoboa.maillog import jobs as maillog_jobs
|
||||
|
||||
register(core_jobs.clean_logs, queue_name="modoboa", cron="0 0 * * *")
|
||||
|
||||
# Random start for this one to avoid a DDoS on the API...
|
||||
minute = random.randint(1, 59)
|
||||
hour = random.randint(0, 6)
|
||||
register(
|
||||
core_jobs.communicate_with_public_api,
|
||||
queue_name="modoboa",
|
||||
cron=f"{minute} {hour},{hour + 12} * * *",
|
||||
)
|
||||
|
||||
register(admin_jobs.handle_mailbox_operations, queue_name="dovecot", cron="* * * * *")
|
||||
|
||||
register(maillog_jobs.logparser, queue_name="modoboa", cron="*/5 * * * *")
|
||||
register(maillog_jobs.update_statistics, queue_name="modoboa", cron="0 * * * *")
|
||||
|
||||
register(calendars_jobs.generate_rights, queue_name="modoboa", cron="*/2 * * * *")
|
||||
|
||||
if "modoboa.amavis" in settings.MODOBOA_APPS:
|
||||
register(amavis_jobs.qcleanup, queue="modoboa", cron="0 0 * * *")
|
||||
register(amavis_jobs.amnotify, queue="modoboa", cron="0 12 * * *")
|
||||
|
||||
Reference in New Issue
Block a user