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

global fixes for uwsgi and django

This commit is contained in:
Jean-Baptiste Holcroft 2017-09-20 15:14:35 +02:00
parent 0c17af017f
commit f2e03b9892
5 changed files with 23 additions and 24 deletions

View file

@ -1,9 +1,9 @@
# https://docs.weblate.org/en/latest/admin/install.html#production-cron # https://docs.weblate.org/en/latest/admin/install.html#production-cron
# Fulltext index updates # Fulltext index updates
10 * * * * www-data cd "__FINALPATH__" && source __FINALPATH__/venv/bin/activate && DJANGO_SETTINGS_MODULE="weblate.settings" weblate update_index 10 * * * * root cd "__FINALPATH__" && source __FINALPATH__/venv/bin/activate && DJANGO_SETTINGS_MODULE="weblate.settings" weblate update_index
# Cleanup stale objects # Cleanup stale objects
@daily cd "__FINALPATH__" && source __FINALPATH__/venv/bin/activate && DJANGO_SETTINGS_MODULE="weblate.settings" weblate cleanuptrans @daily root cd "__FINALPATH__" && source __FINALPATH__/venv/bin/activate && DJANGO_SETTINGS_MODULE="weblate.settings" weblate cleanuptrans
# Commit pending changes after 96 hours # Commit pending changes after 96 hours
@hourly cd "__FINALPATH__" && source __FINALPATH__/venv/bin/activate && DJANGO_SETTINGS_MODULE="weblate.settings" weblate commit_pending --all --age=96 --verbosity=0 @hourly root cd "__FINALPATH__" && source __FINALPATH__/venv/bin/activate && DJANGO_SETTINGS_MODULE="weblate.settings" weblate commit_pending --all --age=96 --verbosity=0

View file

@ -6,9 +6,9 @@ location __PATH__ {
include uwsgi_params; include uwsgi_params;
# Needed for long running operations in admin interface # Needed for long running operations in admin interface
uwsgi_read_timeout 3600; uwsgi_read_timeout 3600;
# Adjust based to uwsgi configuration: uwsgi_param SCRIPT_NAME /__PATH__;
uwsgi_pass unix:///var/run/uwsgi/__NAME__.socket; uwsgi_modifier1 30;
# uwsgi_pass 127.0.0.1:8080; uwsgi_pass unix:///var/run/uwsgi/app/__NAME__/socket;
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;

View file

@ -2,7 +2,7 @@
plugins = python plugins = python
master = true master = true
protocol = uwsgi protocol = uwsgi
socket = unix:///var/run/uwsgi/__NAME__.socket socket = /var/run/uwsgi/app/__NAME__/socket
virtualenv = __FINALPATH__/venv virtualenv = __FINALPATH__/venv
wsgi-file = __FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py wsgi-file = __FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py
python-path = __FINALPATH__/venv python-path = __FINALPATH__/venv

View file

@ -1,16 +1,16 @@
[Unit] [Unit]
Description=uWSGI instance to weblate Description=uWSGI instance for __NAME__
Requires=network.target Requires=network.target
After=network.target After=network.target
[Service] [Service]
User=__NAME__ User=root
Group=__NAME__ Group=root
RemainAfterExit=yes RemainAfterExit=yes
WorkingDirectory=__FINALPATH__ WorkingDirectory=__FINALPATH__
ExecStart=/usr/bin/uwsgi \ ExecStart=/usr/bin/uwsgi \
--ini-paste /etc/uwsgi/apps-enabled/__NAME__.uwsgi.ini \ --ini /etc/uwsgi/apps-enabled/__NAME__.uwsgi.ini \
--socket /var/run/uwsgi/__NAME__.socket --socket /var/run/uwsgi/app/__NAME__/socket
Restart=always Restart=always
StandardError=syslog StandardError=syslog

View file

@ -73,7 +73,7 @@ ynh_app_setting_set "$app" is_public "$is_public"
ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \
libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \ libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \
postgresql libpq-dev uwsgi postgresql libpq-dev uwsgi uwsgi-plugin-python
#================================================= #=================================================
# CREATE A PostgreSQL DATABASE # CREATE A PostgreSQL DATABASE
@ -117,19 +117,17 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/uwsgi.ini"
# Config service # Config service
mkdir -p /etc/uwsgi/apps-enabled/ mkdir -p /etc/uwsgi/apps-enabled/
ln -s "$final_path/uwsgi.ini" "/etc/uwsgi/apps-enabled/$app.uwsgi.ini" ln -s "$final_path/uwsgi.ini" "/etc/uwsgi/apps-enabled/$app.ini"
cp ../conf/uwsgi_service "/etc/systemd/system/$app.uwsgi.service"
ynh_replace_string "__NAME__" "$app" "/etc/systemd/system/$app.uwsgi.service"
ynh_replace_string "__FINALPATH__" "$final_path" "/etc/systemd/system/$app.uwsgi.service"
cp ../conf/uwsgi_service "/etc/systemd/system/$app.service"
ynh_replace_string "__NAME__" "$app" "/etc/systemd/system/$app.service"
ynh_replace_string "__FINALPATH__" "$final_path" "/etc/systemd/system/$app.service"
# Start service # Start service
systemctl enable "$app.uwsgi.service" systemctl enable "$app.service"
systemctl restart "$app.uwsgi.service"
# Add weblate.uwsgi as a service # Add weblate as a service
yunohost service add "$app.uwsgi.service" yunohost service add "$app.service"
#================================================= #=================================================
# PIP INSTALLATION # PIP INSTALLATION
@ -170,7 +168,6 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/venv/lib/python2.7
#========================================== #==========================================
( (
set +eu set +eu
su - weblate
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
export DJANGO_SETTINGS_MODULE="weblate.settings" export DJANGO_SETTINGS_MODULE="weblate.settings"
cd "${final_path}" cd "${final_path}"
@ -200,7 +197,8 @@ ynh_store_file_checksum "$final_path/venv/lib/python2.7/site-packages/weblate/se
#================================================= #=================================================
# Set permissions to app files # Set permissions to app files
chown -R root: "$final_path" chown -R "$app": "$final_path"
chown -R 777 /var/run/uwsgi/app/$app/
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -228,4 +226,5 @@ fi
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
systemctl start "$app.service"
systemctl reload nginx systemctl reload nginx