From cd5d93ca52c5d915ce6b9d35c193b6d358ecc6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Tue, 9 Feb 2021 10:07:52 +0100 Subject: [PATCH] misc: add uwsgi spooler (#50723) --- chrono/utils/spooler.py | 16 ++++++++++++++++ debian/chrono.dirs | 1 + debian/chrono.init | 1 + debian/chrono.service | 3 ++- debian/control | 3 ++- debian/uwsgi.ini | 2 ++ 6 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 chrono/utils/spooler.py diff --git a/chrono/utils/spooler.py b/chrono/utils/spooler.py new file mode 100644 index 00000000..57190b86 --- /dev/null +++ b/chrono/utils/spooler.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# chrono - agendas system +# Copyright (C) 2021 Entr'ouvert +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . diff --git a/debian/chrono.dirs b/debian/chrono.dirs index 15a893a5..27dee360 100644 --- a/debian/chrono.dirs +++ b/debian/chrono.dirs @@ -1,5 +1,6 @@ /etc/chrono /usr/lib/chrono /var/lib/chrono/collectstatic +/var/lib/chrono/spooler /var/lib/chrono/tenants /var/log/chrono diff --git a/debian/chrono.init b/debian/chrono.init index 487fcfc8..5b9537a4 100644 --- a/debian/chrono.init +++ b/debian/chrono.init @@ -38,6 +38,7 @@ GROUP=$NAME DAEMON_ARGS=${DAEMON_ARGS:-"--pidfile=$PIDFILE --uid $USER --gid $GROUP --ini /etc/$NAME/uwsgi.ini +--spooler /var/lib/$NAME/spooler/ --daemonize /var/log/uwsgi.$NAME.log"} # Load the VERBOSE setting and other rcS variables diff --git a/debian/chrono.service b/debian/chrono.service index 00fec975..f8cb16b5 100644 --- a/debian/chrono.service +++ b/debian/chrono.service @@ -10,7 +10,8 @@ User=%p Group=%p ExecStartPre=/usr/bin/chrono-manage migrate_schemas --noinput --verbosity 1 ExecStartPre=/usr/bin/chrono-manage collectstatic --noinput -ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini +ExecStartPre=/bin/mkdir -p /var/lib/chrono/spooler/%m/ +ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini --spooler /var/lib/chrono/spooler/%m/ ExecReload=/bin/kill -HUP $MAINPID KillSignal=SIGQUIT TimeoutStartSec=0 diff --git a/debian/control b/debian/control index d734e757..56578f6b 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,8 @@ Architecture: all Depends: ${misc:Depends}, ${python3:Depends}, python3-django (>= 1:1.11), python3-gadjo, - python3-requests + python3-requests, + python3-uwsgidecorators Recommends: python3-django-mellon Description: Agendas System (Python 3 module) diff --git a/debian/uwsgi.ini b/debian/uwsgi.ini index e5d6c60f..96b41474 100644 --- a/debian/uwsgi.ini +++ b/debian/uwsgi.ini @@ -12,6 +12,8 @@ http-socket = /run/chrono/chrono.sock chmod-socket = 666 vacuum = true +spooler-processes = 3 +spooler-python-import = chrono.utils.spooler # every five minutes cron = -5 -1 -1 -1 -1 /usr/bin/chrono-manage tenant_command cancel_events --all-tenants -v0 cron = -5 -1 -1 -1 -1 /usr/bin/chrono-manage tenant_command send_email_notifications --all-tenants -v0