1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

Improve uwsgi helper (path, mount, mask) and fix installation

This commit is contained in:
Jean-Baptiste Holcroft 2017-12-17 17:19:48 +01:00
parent 3af0b44f7e
commit 0c36004d03
6 changed files with 27 additions and 32 deletions

View file

@ -6,8 +6,6 @@ location __PATH__ {
include uwsgi_params;
# Needed for long running operations in admin interface
uwsgi_read_timeout 3600;
uwsgi_param SCRIPT_NAME __PATH__;
uwsgi_modifier1 30;
uwsgi_pass unix:///var/run/uwsgi/__NAME__.socket;
# Include SSOWAT user panel.

View file

@ -4,14 +4,15 @@ master = true
protocol = uwsgi
socket = /var/run/uwsgi/__APP__.socket
virtualenv = __FINALPATH__/venv
wsgi-file = __FINALPATH__/venv/lib/python3.4/site-packages/weblate/wsgi.py
# http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info
mount = __PATH__=__FINALPATH__/venv/lib/python3.4/site-packages/weblate/wsgi.py
manage-script-name = true
# Needed for OAuth/OpenID
buffer-size = 8192
# Increase number of workers for heavily loaded sites
#workers = 6
# Needed for background processing
enable-threads = true
# Child processes do not need file descriptors
close-on-exec = true
# Avoid default 0000 umask
umask = 0022

View file

@ -33,9 +33,12 @@ ynh_check_global_uwsgi_config () {
# this helper :
#
# __APP__ by $app
# __PATH__ by $path_url
# __FINALPATH__ by $final_path
#
# usage: ynh_add_systemd_config
#
# to interact with your service: `systemctl <action> uwsgi-app@app`
ynh_add_uwsgi_service () {
ynh_check_global_uwsgi_config
@ -51,6 +54,9 @@ ynh_add_uwsgi_service () {
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini"
fi
if test -n "${path_url:-}"; then
ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini"
fi
if test -n "${app:-}"; then
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
fi

View file

@ -93,10 +93,6 @@ settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
if [ "$old_path" == "/" ] && [ "$new_path" != "/" ]
then
# uwsgi_param is only needed for non-root installation
ynh_replace_string "#uwsgi_param " "uwsgi_param " "$finalnginxconf"
ynh_replace_string "#uwsgi_modifier1 " "uwsgi_modifier1 " "$finalnginxconf"
if [ "$is_public" -eq 0 ]
then
# ynh panel is only comptable with non-root installation
@ -111,9 +107,6 @@ fi
if [ "$old_path" != "/" ] && [ "$new_path" == "/" ]
then
# uwsgi_param is only needed for non-root installation
ynh_replace_string "uwsgi_param " "#uwsgi_param " "$finalnginxconf"
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
# ynh panel is only comptable with non-root installation
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"

View file

@ -105,9 +105,6 @@ ynh_add_nginx_config
if [ "$path_url" == "/" ]
then
# $finalnginxconf comes from ynh_add_nginx_config
# uwsgi_param is only needed for non-root installation
ynh_replace_string "uwsgi_param " "#uwsgi_param " "$finalnginxconf"
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
ynh_replace_string "location //" "location /" "$finalnginxconf"
# ynh panel is only comptable with non-root installation
@ -188,11 +185,11 @@ virtualenv --python=python3 "${final_path}/venv"
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
"${final_path}/venv/bin/pip" install --upgrade pip
"${final_path}/venv/bin/pip" install Weblate=="$current_version"
"${final_path}/venv/bin/pip" install python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2 python-memcached
pip install --upgrade pip
pip install Weblate=="$current_version"
pip install python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2 python-memcached
# specific to YunoHost package:
"${final_path}/venv/bin/pip" install django_sendmail_backend
pip install django_sendmail_backend
)
#=================================================

View file

@ -44,10 +44,11 @@ fi
#=================================================
(
set +eu
set +o nounset
source "${final_path}/venv/bin/activate"
"${final_path}/venv/bin/pip" install --upgrade pip
"${final_path}/venv/bin/pip" freeze --local > freeze.pip
set -o nounset
pip install --upgrade pip
pip freeze --local > freeze.pip
)
previous_version=$(cat freeze.pip | grep "Weblate==" | sed "s|Weblate==||")
@ -101,9 +102,6 @@ ynh_add_nginx_config
if [ "$path_url" == "/" ]
then
# $finalnginxconf comes from ynh_add_nginx_config
# uwsgi_param is only needed for non-root installation
ynh_replace_string "uwsgi_param " "#uwsgi_param " "$finalnginxconf"
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
ynh_replace_string "location //" "location /" "$finalnginxconf"
# ynh panel is only comptable with non-root installation
@ -136,12 +134,13 @@ old_settings="./settings.$previous_version.old.py"
settings_diff="$final_path/settings.${previous_version}_${current_version}.diff"
(
set +eu
set +o nounset
source "${final_path}/venv/bin/activate"
"${final_path}/venv/bin/pip" install Weblate=="$current_version"
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
set -o nounset
pip install Weblate=="$current_version"
pip install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
# specific to YunoHost package:
"${final_path}/venv/bin/pip" install django_sendmail_backend
pip install django_sendmail_backend
)
check=$(ynh_check_if_checksum_is_different "$settings")
@ -205,8 +204,9 @@ fi
#=================================================
(
set +eu
source ${final_path}/venv/bin/activate
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
export DJANGO_SETTINGS_MODULE="weblate.settings"
cd "${final_path}"
weblate migrate --noinput