From d69e379fad68903d780feac66ae68c71d2b018ee Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 17 Feb 2021 10:54:20 +0100 Subject: [PATCH 3/4] misc: add uwsgi spooler (#50891) --- combo/utils/spooler.py | 15 +++++++++++++++ debian/combo.dirs | 1 + debian/combo.init | 1 + debian/combo.postinst | 1 + debian/combo.service | 3 ++- debian/control | 3 ++- debian/uwsgi.ini | 3 +++ 7 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 combo/utils/spooler.py diff --git a/combo/utils/spooler.py b/combo/utils/spooler.py new file mode 100644 index 00000000..05235467 --- /dev/null +++ b/combo/utils/spooler.py @@ -0,0 +1,15 @@ +# combo - content management 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/combo.dirs b/debian/combo.dirs index 43498322..74e9cb57 100644 --- a/debian/combo.dirs +++ b/debian/combo.dirs @@ -4,3 +4,4 @@ /var/lib/combo/collectstatic /var/lib/combo/tenants /var/log/combo +/var/lib/combo/spooler diff --git a/debian/combo.init b/debian/combo.init index e379e794..0528fc56 100644 --- a/debian/combo.init +++ b/debian/combo.init @@ -39,6 +39,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/combo.postinst b/debian/combo.postinst index cf90ec74..3f0d24df 100644 --- a/debian/combo.postinst +++ b/debian/combo.postinst @@ -21,6 +21,7 @@ case "$1" in chown $USER:$GROUP /var/log/$NAME chown $USER:$GROUP /var/lib/$NAME/collectstatic chown $USER:$GROUP /var/lib/$NAME/tenants + chown $USER:$GROUP /var/lib/$NAME/spooler # create a secret file SECRET_FILE=$CONFIG_DIR/secret if [ ! -f $SECRET_FILE ]; then diff --git a/debian/combo.service b/debian/combo.service index 13525f98..cd37dc2c 100644 --- a/debian/combo.service +++ b/debian/combo.service @@ -10,7 +10,8 @@ User=%p Group=%p ExecStartPre=/usr/bin/combo-manage migrate_schemas --noinput --verbosity 1 ExecStartPre=/usr/bin/combo-manage collectstatic --noinput -ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini +ExecStartPre=/bin/mkdir -p /var/lib/combo/spooler/%m/ +ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini --spooler /var/lib/combo/spooler/%m/ ExecReload=/bin/kill -HUP $MAINPID KillSignal=SIGQUIT TimeoutStartSec=0 diff --git a/debian/control b/debian/control index c022da9d..27e46eb6 100644 --- a/debian/control +++ b/debian/control @@ -41,7 +41,8 @@ Depends: ${misc:Depends}, python3-psycopg2, python3-django-mellon (>= 1.13), uwsgi, - uwsgi-plugin-python3 + uwsgi-plugin-python3, + python3-uwsgidecorators Recommends: nginx Suggests: postgresql Breaks: python-combo (<< 2.34.post2) diff --git a/debian/uwsgi.ini b/debian/uwsgi.ini index 66cf6a46..05eff4ef 100644 --- a/debian/uwsgi.ini +++ b/debian/uwsgi.ini @@ -9,6 +9,9 @@ http-socket = /run/combo/combo.sock chmod-socket = 666 vacuum = true +spooler-processes = 3 +spooler-python-import = combo.utils.spooler + master = true processes = 5 harakiri = 120 -- 2.20.1