Merge pull request #462 from Spitfireap/randomize-api-call-time
randomize api call time
This commit is contained in:
@@ -30,7 +30,7 @@ INSTANCE=%{instance_path}
|
|||||||
*/30 * * * * root $PYTHON $INSTANCE/manage.py modo check_mx
|
*/30 * * * * root $PYTHON $INSTANCE/manage.py modo check_mx
|
||||||
|
|
||||||
# Public API communication
|
# Public API communication
|
||||||
0 * * * * root $PYTHON $INSTANCE/manage.py communicate_with_public_api
|
%{minutes} %{hours} * * * root $PYTHON $INSTANCE/manage.py communicate_with_public_api
|
||||||
|
|
||||||
# Generate DKIM keys (they will belong to the user running this job)
|
# Generate DKIM keys (they will belong to the user running this job)
|
||||||
%{opendkim_enabled}* * * * * %{opendkim_user} umask 077 && $PYTHON $INSTANCE/manage.py modo manage_dkim_keys
|
%{opendkim_enabled}* * * * * %{opendkim_user} umask 077 && $PYTHON $INSTANCE/manage.py modo manage_dkim_keys
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
import sys
|
import sys
|
||||||
@@ -219,6 +220,7 @@ class Modoboa(base.Installer):
|
|||||||
context = super(Modoboa, self).get_template_context()
|
context = super(Modoboa, self).get_template_context()
|
||||||
extensions = self.config.get("modoboa", "extensions")
|
extensions = self.config.get("modoboa", "extensions")
|
||||||
extensions = extensions.split()
|
extensions = extensions.split()
|
||||||
|
random_hour = random.randint(0, 6)
|
||||||
context.update({
|
context.update({
|
||||||
"sudo_user": (
|
"sudo_user": (
|
||||||
"uwsgi" if package.backend.FORMAT == "rpm" else context["user"]
|
"uwsgi" if package.backend.FORMAT == "rpm" else context["user"]
|
||||||
@@ -228,6 +230,8 @@ class Modoboa(base.Installer):
|
|||||||
"radicale_enabled": (
|
"radicale_enabled": (
|
||||||
"" if "modoboa-radicale" in extensions else "#"),
|
"" if "modoboa-radicale" in extensions else "#"),
|
||||||
"opendkim_user": self.config.get("opendkim", "user"),
|
"opendkim_user": self.config.get("opendkim", "user"),
|
||||||
|
"minutes": random.randint(1, 59),
|
||||||
|
"hours" : f"{random_hour},{random_hour+12}"
|
||||||
})
|
})
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user