From 41bc9875153e10cb6dca90d2bc86fdfb66b4e5fa Mon Sep 17 00:00:00 2001 From: Spitap Date: Fri, 21 Jul 2023 11:33:44 +0200 Subject: [PATCH] Changed user for dkim management --- doc/upgrade.rst | 18 ++++-------------- docker-compose.yml | 2 +- modoboa/admin/handlers.py | 3 ++- .../core/commands/templates/settings.py.tpl | 12 +----------- test_project/test_project/settings.py | 8 +------- 5 files changed, 9 insertions(+), 34 deletions(-) diff --git a/doc/upgrade.rst b/doc/upgrade.rst index 55a7cf021..16a53465e 100644 --- a/doc/upgrade.rst +++ b/doc/upgrade.rst @@ -166,21 +166,11 @@ and add the RQ section bellow the ``#REDIS`` section: # RQ RQ_QUEUES = { - 'default': { + 'dkim': { 'HOST': REDIS_HOST, 'PORT': REDIS_PORT, 'DB': 0, }, - 'high': { - 'HOST': REDIS_HOST, - 'PORT': REDIS_PORT, - 'DB': 0, - }, - 'low': { - 'HOST': REDIS_HOST, - 'PORT': REDIS_PORT, - 'DB': 0, - } } Then by default you will need to restart ``uwsgi`` service (``systemctl restart uwsgi`` on Debian). @@ -192,9 +182,9 @@ Then by default you will need to restart ``uwsgi`` service (``systemctl restart [program:modoboa-worker] autostart=true autorestart=true - command={%python env path%} {% manage.py instance path%} rqworker high default low + command={%python env path%} {% manage.py instance path%} rqworker dkim directory={%modoboa home dir%} - user=%{modoboa user} + user=%{dkim manager user} numprocs=1 stopsignal=TERM @@ -204,7 +194,7 @@ You will find it here ``/srv/modoboa/venv/bin/python`` by default. You will find it here : ``/srv/modoboa/instance/manage.py``by default. ``Modoboa home dir``: Home dir of the user running modooba. You will find it here ``/srv/modoboa/`` by default. -``modoboa user`` : User owning modoboa home dir. +``dkim manager user`` : User managing dkim signing (opendkim by default). You can help you with ``/etc/supervisor/conf.d/policyd.conf`` (by default). diff --git a/docker-compose.yml b/docker-compose.yml index 7de4e402e..7a98b2d29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: DEBUG: "True" REDIS_HOST: redis command: > - sh -c "cd test_project; python3 manage.py rqworker high default low" + sh -c "cd test_project; python3 manage.py rqworker dkim" volumes: - .:/code diff --git a/modoboa/admin/handlers.py b/modoboa/admin/handlers.py index 78ac894e9..4a6fcf15b 100644 --- a/modoboa/admin/handlers.py +++ b/modoboa/admin/handlers.py @@ -51,7 +51,8 @@ def update_domain_mxs_and_mailboxes(sender, instance, **kwargs): def create_dkim_key(sender, instance, **kwargs): if not instance.enable_dkim: return - django_rq.enqueue(call_command, + queue = django_rq.get_queue('dkim') + queue.enqueue(call_command, "modo", "manage_dkim_keys", f"--domain={instance.name}") diff --git a/modoboa/core/commands/templates/settings.py.tpl b/modoboa/core/commands/templates/settings.py.tpl index 7fc8a4a7b..c9e3874ee 100644 --- a/modoboa/core/commands/templates/settings.py.tpl +++ b/modoboa/core/commands/templates/settings.py.tpl @@ -257,21 +257,11 @@ REDIS_URL = 'redis://{}:{}/{}'.format(REDIS_HOST, REDIS_PORT, REDIS_QUOTA_DB) # RQ RQ_QUEUES = { - 'default': { + 'dkim': { 'HOST': REDIS_HOST, 'PORT': REDIS_PORT, 'DB': 0, }, - 'high': { - 'HOST': REDIS_HOST, - 'PORT': REDIS_PORT, - 'DB': 0, - }, - 'low': { - 'HOST': REDIS_HOST, - 'PORT': REDIS_PORT, - 'DB': 0, - } } # Password validation diff --git a/test_project/test_project/settings.py b/test_project/test_project/settings.py index dd3575a04..aa02ff62e 100644 --- a/test_project/test_project/settings.py +++ b/test_project/test_project/settings.py @@ -240,15 +240,9 @@ REDIS_URL = 'redis://{}:{}/{}'.format(REDIS_HOST, REDIS_PORT, REDIS_QUOTA_DB) # RQ RQ_QUEUES = { - 'default': { + 'dkim': { 'URL': REDIS_URL, }, - 'high': { - 'URL': REDIS_URL, - }, - 'low': { - 'URL': REDIS_URL, - } } # Password validation