debian: switch to python 3, uwsgi and native systemd configuration (#44410)

This commit is contained in:
Emmanuel Cazenave 2020-06-25 17:34:35 +02:00
parent 0364ad0ee5
commit a2793266db
11 changed files with 145 additions and 27 deletions

2
debian/compat vendored
View File

@ -1 +1 @@
9
10

39
debian/control vendored
View File

@ -2,30 +2,33 @@ Source: docbow
Maintainer: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Section: python
Priority: optional
Build-Depends: python-setuptools (>= 0.6b3),
python-all (>= 2.6.6-3),
debhelper (>= 8.0),
Build-Depends: python3-setuptools,
python3-all,
debhelper (>= 10),
dh-python,
dh-systemd,
openssl,
python-django (>= 1:1.11),
python3-django (>= 1:1.11),
yelp-tools,
yelp-xsl
Standards-Version: 3.9.1
X-Python-Version: >= 2.7
Standards-Version: 3.9.6
Homepage: https://dev.entrouvert.org/projects/docbow
Package: docbow
Architecture: all
Suggests: postgresql
Depends: ${misc:Depends}, python (>= 2.6),
python-django (>= 1:1.11),
python-django-debug-toolbar,
python-beautifulsoup,
gunicorn,
python-django-journal (>= 2.0.0),
python-django-picklefield (< 2.0.0),
python-django-tables2,
python-requests,
python-magic,
python-psycopg2,
python-django-watson (>= 1.2.0),
Depends: ${python3:Depends},
${misc:Depends},
python3-django (>= 1:1.11),
python3-django-debug-toolbar,
python3-bs4,
python3-django-journal (>= 2.0.0),
python3-django-picklefield (< 2.0.0),
python3-django-tables2,
python3-requests,
python3-magic,
python3-psycopg2,
python3-django-watson (>= 1.2.0),
uwsgi,
uwsgi-plugin-python3
Description: Document Box Wallone

View File

@ -3,9 +3,6 @@
import glob
import os
from django.core.exceptions import ImproperlyConfigured
PROJECT_NAME = 'docbow'
ETC_DIR = os.path.join('/etc', PROJECT_NAME)
@ -13,7 +10,7 @@ ETC_SETTINGS_PY = os.path.join(ETC_DIR, 'settings.py')
if os.path.exists(ETC_SETTINGS_PY):
execfile(ETC_SETTINGS_PY)
exec(open(ETC_SETTINGS_PY).read())
for filename in sorted(glob.glob(os.path.join(ETC_DIR, 'settings.d', '*.py'))):
execfile(filename)
exec(open(filename).read())

25
debian/docbow-manage vendored Normal file
View File

@ -0,0 +1,25 @@
#!/bin/sh
NAME=docbow
MANAGE=/usr/lib/$NAME/manage.py
# load Debian default configuration
export DOCBOW_SETTINGS_FILE=/usr/lib/$NAME/debian_config.py
# check user
if test x$1 = x"--forceuser"
then
shift
elif test $(id -un) != "$NAME"
then
echo "error: must use $0 with user ${NAME}"
exit 1
fi
if test $# -eq 0
then
python3 ${MANAGE} help
exit 1
fi
python3 ${MANAGE} "$@"

26
debian/docbow.service vendored Normal file
View File

@ -0,0 +1,26 @@
[Unit]
Description=Docbow
After=network.target syslog.target postgresql.service
Wants=postgresql.service
[Service]
Environment=DOCBOW_SETTINGS_FILE=/usr/lib/%p/debian_config.py
Environment=LANG=fr_FR.UTF-8
Environment=LC_ALL=fr_FR.UTF-8
User=%p
Group=%p
ExecStartPre=/usr/bin/docbow-manage migrate --noinput --verbosity 1
ExecStartPre=/usr/bin/docbow-manage collectstatic --noinput
ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStartSec=0
PrivateTmp=true
Restart=on-failure
RuntimeDirectory=docbow
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target

2
debian/install vendored
View File

@ -1,3 +1,5 @@
debian/conf/docbow.nginx /etc/nginx/sites-available/
debian/conf/magic /usr/share/docbow
debian/debian_config.py /usr/lib/docbow
debian/docbow-manage /usr/bin
debian/uwsgi.ini /etc/docbow

4
debian/py3dist-overrides vendored Normal file
View File

@ -0,0 +1,4 @@
django_watson python3-django-watson
django_journal python3-django-journal
python_magic python3-magic
typing

8
debian/rules vendored
View File

@ -1,9 +1,15 @@
#!/usr/bin/make -f
# -*- makefile -*-
export PYBUILD_NAME=docbow
export PYBUILD_DISABLE=test
%:
dh $@ --with python2 --buildsystem=pybuild
dh $@ --with python3,systemd --buildsystem=pybuild
override_dh_install:
dh_install
mv $(CURDIR)/debian/docbow/usr/bin/manage.py $(CURDIR)/debian/docbow/usr/lib/docbow/manage.py
override_dh_auto_build:
$(MAKE) -C help/fr

45
debian/uwsgi.ini vendored Normal file
View File

@ -0,0 +1,45 @@
[uwsgi]
strict = true
auto-procname = true
procname-prefix-spaced = docbow
plugin = python3
single-interpreter = true
module = docbow_project.wsgi:application
need-app = true
vacuum = true
http-socket = /run/docbow/docbow.sock
chmod-socket = 666
vacuum = true
master = true
enable-threads = true
harakiri = 120
plugin = cheaper_busyness
cheaper-algo = busyness
processes = 500
cheaper = 5
cheaper-initial = 10
cheaper-overload = 5
cheaper-step = 10
cheaper-busyness-multiplier = 30
cheaper-busyness-min = 20
cheaper-busyness-max = 70
cheaper-busyness-backlog-alert = 16
cheaper-busyness-backlog-step = 2
max-requests = 500
max-worker-lifetime = 7200
buffer-size = 32768
py-tracebacker = /run/docbow/py-tracebacker.sock.
stats = /run/docbow/stats.sock
ignore-sigpipe = true
if-file = /etc/docbow/uwsgi-local.ini
include = /etc/docbow/uwsgi-local.ini
endif =

10
manage.py Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python3
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "docbow_project.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

View File

@ -40,7 +40,7 @@ def get_version():
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
if '-' in result: # not a tagged version
real_number, commit_count, commit_hash = result.split('-', 2)
version = '%s.post%s' % (real_number, commit_count)
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
else:
version = result
return version
@ -95,7 +95,7 @@ setup(name='docbow',
maintainer='Benjamin Dauvergne',
maintainer_email='bdauvergne@entrouvert.com',
include_package_data=True,
scripts=('docbow-ctl',),
scripts=('manage.py',),
packages=find_packages(),
install_requires=[
'django>=1.11, <2',