debian: add systemd service file and replace gunicorn by uwsgi (fixes #21114)

This commit is contained in:
Benjamin Dauvergne 2018-01-11 15:03:40 +01:00
parent d8887ad7a8
commit c39bf2773e
7 changed files with 64 additions and 31 deletions

2
debian/compat vendored
View File

@ -1 +1 @@
7
8

11
debian/control vendored
View File

@ -2,7 +2,7 @@ Source: petale
Maintainer: Josue Kouka <jkouka@entrouvert.org>
Section: python
Priority: optional
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 7), python-django
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 7), python-django, dh-systemd, dh-python
Standards-Version: 3.9.6
X-Python-Version: >= 2.7
@ -13,13 +13,14 @@ Depends: ${misc:Depends}, ${python:Depends},
python-django-jsonfield,
python-djangorestframework,
python-requests,
Description: Simple App as Key Value Interface Storage
Description: Simple key value datastore
Package: petale
Architecture: all
Depends: ${misc:Depends},
gunicorn,
python-petale (= ${binary:Version}),
python-psycopg2,
Recommends: nginx, postgresql
Description: Simple App as Key Value Interface Storage
uwsgi,
uwsgi-plugin-python
Recommends: nginx
Description: Simple key value datastore

33
debian/petale.init vendored
View File

@ -7,24 +7,19 @@
# Should-stop: postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Authentication Reverse Proxy
# Description: Authentication Reverse Proxy
# Short-Description: Petale key value datastore
# Description: Petale key value datastore
### END INIT INFO
# Author: Entr'ouvert <info@entrouvert.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Authentication Reverse Proxy"
DESC="Petale key value datastore"
NAME=petale
DAEMON=/usr/bin/gunicorn
DAEMON=/usr/bin/uwsgi
RUN_DIR=/run/$NAME
PIDFILE=$RUN_DIR/$NAME.pid
LOG_DIR=/var/log/$NAME
SCRIPTNAME=/etc/init.d/$NAME
BIND=unix:$RUN_DIR/$NAME.sock
WORKERS=5
TIMEOUT=30
LOG_LEVEL=debug
PETALE_SETTINGS_FILE=/usr/lib/$NAME/debian_config.py
MANAGE_SCRIPT="/usr/bin/$NAME-manage"
@ -38,18 +33,10 @@ GROUP=$NAME
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
DAEMON_ARGS=${DAEMON_ARGS:-"--pid $PIDFILE \
--user $USER --group $GROUP \
--daemon \
--access-logfile $LOG_DIR/gunicorn-access.log \
--log-file $LOG_DIR/gunicorn-error.log \
--log-level=$LOG_LEVEL \
--bind=$BIND \
--workers=$WORKERS \
--worker-class=sync \
--timeout=$TIMEOUT \
--name $NAME \
$NAME.wsgi:application"}
DAEMON_ARGS=${DAEMON_ARGS:-"--pidfile $PIDFILE
--uid $USER --gid $GROUP
--ini /etc/$NAME/uwsgi.ini
--daemonize /var/log/uwsgi.$NAME.log"}
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
@ -122,8 +109,8 @@ do_reload() {
}
do_migrate() {
log_action_msg "Applying migrations (migrate_schemas).."
su $USER -s /bin/sh -p -c "$MANAGE_SCRIPT migrate_schemas"
log_action_msg "Applying migrations.."
su $USER -s /bin/sh -p -c "$MANAGE_SCRIPT migrate --noinput"
log_action_msg "done"
}

View File

@ -1,3 +1,4 @@
debian/petale-manage /usr/bin
debian/petale-manage /usr/bin
debian/settings.py /etc/petale
debian/debian_config.py /usr/lib/petale
debian/uwsgi.ini /etc/petale

24
debian/petale.service vendored Normal file
View File

@ -0,0 +1,24 @@
[Unit]
Description=Petale key value datastore
After=network.target syslog.target postgresql.service
Wants=postgresql.service
[Service]
Environment=PETALE_SETTINGS_FILE=/usr/lib/%p/debian_config.py
User=%p
Group=%p
ExecStartPre=/usr/bin/petale-manage migrate --noinput
ExecStartPre=/usr/bin/petale-manage collectstatic --noinput
ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGQUIT
PrivateTmp=true
Restart=on-failure
RuntimeDirectory=petale
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target

2
debian/rules vendored
View File

@ -5,4 +5,4 @@
#export DH_VERBOSE=1
%:
dh $@ --with python2
dh $@ --with python2,systemd

20
debian/uwsgi.ini vendored Normal file
View File

@ -0,0 +1,20 @@
[uwsgi]
auto-procname = true
procname-prefix-spaced = petale
plugin = python
module = petale.wsgi:application
http-socket = /run/petale/petale.sock
chmod-socket = 666
vacuum = true
master = true
processes = 5
harakiri = 30
buffer-size = 32768
if-file = /etc/petale/uwsgi-local.ini
include = /etc/petale/uwsgi-local.ini
endif =