diff --git a/conf/cron_weblate b/conf/cron_weblate index 0e43728..1358532 100644 --- a/conf/cron_weblate +++ b/conf/cron_weblate @@ -1,9 +1,9 @@ # https://docs.weblate.org/en/latest/admin/install.html#production-cron # 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 -@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 -@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 diff --git a/conf/nginx.conf b/conf/nginx.conf index 738143d..ada9ce5 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,9 +6,9 @@ location __PATH__ { include uwsgi_params; # Needed for long running operations in admin interface uwsgi_read_timeout 3600; - # Adjust based to uwsgi configuration: - uwsgi_pass unix:///var/run/uwsgi/__NAME__.socket; - # uwsgi_pass 127.0.0.1:8080; + uwsgi_param SCRIPT_NAME /__PATH__; + uwsgi_modifier1 30; + uwsgi_pass unix:///var/run/uwsgi/app/__NAME__/socket; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index d5d8394..18afaaa 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -2,7 +2,7 @@ plugins = python master = true protocol = uwsgi -socket = unix:///var/run/uwsgi/__NAME__.socket +socket = /var/run/uwsgi/app/__NAME__/socket virtualenv = __FINALPATH__/venv wsgi-file = __FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py python-path = __FINALPATH__/venv diff --git a/conf/uwsgi_service b/conf/uwsgi_service index 9f669da..b69f77d 100644 --- a/conf/uwsgi_service +++ b/conf/uwsgi_service @@ -1,16 +1,16 @@ [Unit] -Description=uWSGI instance to weblate +Description=uWSGI instance for __NAME__ Requires=network.target After=network.target [Service] -User=__NAME__ -Group=__NAME__ +User=root +Group=root RemainAfterExit=yes WorkingDirectory=__FINALPATH__ ExecStart=/usr/bin/uwsgi \ - --ini-paste /etc/uwsgi/apps-enabled/__NAME__.uwsgi.ini \ - --socket /var/run/uwsgi/__NAME__.socket + --ini /etc/uwsgi/apps-enabled/__NAME__.uwsgi.ini \ + --socket /var/run/uwsgi/app/__NAME__/socket Restart=always StandardError=syslog diff --git a/scripts/install b/scripts/install index 9596be8..572c4d1 100755 --- a/scripts/install +++ b/scripts/install @@ -73,7 +73,7 @@ ynh_app_setting_set "$app" is_public "$is_public" ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ 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 @@ -117,19 +117,17 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/uwsgi.ini" # Config service mkdir -p /etc/uwsgi/apps-enabled/ -ln -s "$final_path/uwsgi.ini" "/etc/uwsgi/apps-enabled/$app.uwsgi.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" +ln -s "$final_path/uwsgi.ini" "/etc/uwsgi/apps-enabled/$app.ini" +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 -systemctl enable "$app.uwsgi.service" -systemctl restart "$app.uwsgi.service" +systemctl enable "$app.service" -# Add weblate.uwsgi as a service -yunohost service add "$app.uwsgi.service" +# Add weblate as a service +yunohost service add "$app.service" #================================================= # PIP INSTALLATION @@ -170,7 +168,6 @@ ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/venv/lib/python2.7 #========================================== ( set +eu - su - weblate source "${final_path}/venv/bin/activate" export DJANGO_SETTINGS_MODULE="weblate.settings" 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 -chown -R root: "$final_path" +chown -R "$app": "$final_path" +chown -R 777 /var/run/uwsgi/app/$app/ #================================================= # SETUP LOGROTATE @@ -228,4 +226,5 @@ fi # RELOAD NGINX #================================================= +systemctl start "$app.service" systemctl reload nginx