From 62d9e34b8f6849328171676d1a464679b5ebc11c Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Fri, 4 Dec 2015 15:15:11 +0000 Subject: Add a cron job for Mailman 3 --- roles/mailman/files/periodic.py | 23 +++++++++++++++++++++++ roles/mailman/tasks/main.yml | 8 +++++++- roles/mailman/templates/crontab-mailman3.j2 | 1 + roles/mailman/templates/crontab-webui.j2 | 11 +++++++++++ roles/mailman/templates/crontab.j2 | 11 ----------- 5 files changed, 42 insertions(+), 12 deletions(-) create mode 100755 roles/mailman/files/periodic.py create mode 100644 roles/mailman/templates/crontab-mailman3.j2 create mode 100644 roles/mailman/templates/crontab-webui.j2 delete mode 100644 roles/mailman/templates/crontab.j2 diff --git a/roles/mailman/files/periodic.py b/roles/mailman/files/periodic.py new file mode 100755 index 000000000..73dcee08c --- /dev/null +++ b/roles/mailman/files/periodic.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 + +import os +import sys + +from mailman.core.initialize import initialize +from mailman.config import config +from mailman.interfaces.pending import IPendings +from mailman.interfaces.requests import IListRequests, RequestType +from zope.component import getUtility + + +def clean_pended(): + getUtility(IPendings).evict() + + +if __name__ == '__main__': + if os.getuid() == 0: + print("This script must be run as the mailman user", file=sys.stderr) + sys.exit(1) + initialize(config_path="/etc/mailman.cfg") + clean_pended() + config.db.commit() diff --git a/roles/mailman/tasks/main.yml b/roles/mailman/tasks/main.yml index 29eef4515..133b3d930 100644 --- a/roles/mailman/tasks/main.yml +++ b/roles/mailman/tasks/main.yml @@ -193,7 +193,12 @@ # Crontab # - name: set the hyperkitty crontab - template: src=crontab.j2 dest=/etc/cron.d/hyperkitty + template: src=crontab-webui.j2 dest=/etc/cron.d/hyperkitty + tags: + - config + - mailman +- name: set the mailman crontab + template: src=crontab-mailman3.j2 dest=/etc/cron.d/mailman3 tags: - config - mailman @@ -367,6 +372,7 @@ - pg-give-rights.py - post-update.sh - import-mm2.py + - periodic.py - name: copy the initial user fixture copy: src=postorius.initial-user.json diff --git a/roles/mailman/templates/crontab-mailman3.j2 b/roles/mailman/templates/crontab-mailman3.j2 new file mode 100644 index 000000000..5be2306c6 --- /dev/null +++ b/roles/mailman/templates/crontab-mailman3.j2 @@ -0,0 +1 @@ +42 * * * * mailman {{ mailman_webui_basedir }}/bin/periodic.py diff --git a/roles/mailman/templates/crontab-webui.j2 b/roles/mailman/templates/crontab-webui.j2 new file mode 100644 index 000000000..380ffb5bf --- /dev/null +++ b/roles/mailman/templates/crontab-webui.j2 @@ -0,0 +1,11 @@ +# This goes in /etc/cron.d/. +# Replace "apache" by your webserver user ("www-data" on Debian systems) and +# set the path to the Django project directory + +@hourly apache django-admin runjobs hourly --pythonpath {{ mailman_webui_confdir }} --settings settings +@daily apache django-admin runjobs daily --pythonpath {{ mailman_webui_confdir }} --settings settings +@weekly apache django-admin runjobs weekly --pythonpath {{ mailman_webui_confdir }} --settings settings +@monthly apache django-admin runjobs monthly --pythonpath {{ mailman_webui_confdir }} --settings settings +@yearly apache django-admin runjobs yearly --pythonpath {{ mailman_webui_confdir }} --settings settings +2,17,32,47 * * * * apache django-admin runjobs quarter_hourly --pythonpath {{ mailman_webui_confdir }} --settings settings +* * * * * apache django-admin runjobs minutely --pythonpath {{ mailman_webui_confdir }} --settings settings diff --git a/roles/mailman/templates/crontab.j2 b/roles/mailman/templates/crontab.j2 deleted file mode 100644 index 380ffb5bf..000000000 --- a/roles/mailman/templates/crontab.j2 +++ /dev/null @@ -1,11 +0,0 @@ -# This goes in /etc/cron.d/. -# Replace "apache" by your webserver user ("www-data" on Debian systems) and -# set the path to the Django project directory - -@hourly apache django-admin runjobs hourly --pythonpath {{ mailman_webui_confdir }} --settings settings -@daily apache django-admin runjobs daily --pythonpath {{ mailman_webui_confdir }} --settings settings -@weekly apache django-admin runjobs weekly --pythonpath {{ mailman_webui_confdir }} --settings settings -@monthly apache django-admin runjobs monthly --pythonpath {{ mailman_webui_confdir }} --settings settings -@yearly apache django-admin runjobs yearly --pythonpath {{ mailman_webui_confdir }} --settings settings -2,17,32,47 * * * * apache django-admin runjobs quarter_hourly --pythonpath {{ mailman_webui_confdir }} --settings settings -* * * * * apache django-admin runjobs minutely --pythonpath {{ mailman_webui_confdir }} --settings settings -- cgit