Rewrite uwsgi to use the helper

This commit is contained in:
Jean-Baptiste Holcroft
2018-07-05 23:21:03 +02:00
parent 613527af71
commit f6682e66ac
10 changed files with 190 additions and 83 deletions

View File

@@ -63,7 +63,7 @@ if [ -e /opt/yunohost/ffsync ]; then
ynh_secure_remove /var/log/ffsync.log
ynh_secure_remove /opt/yunohost/ffsync
ynh_add_systemd_config
yunohost service remove "$app"
fi
#=================================================
@@ -96,6 +96,12 @@ path_url=$(ynh_normalize_url_path "$path_url")
ynh_install_app_dependencies python-dev python-virtualenv \
uwsgi uwsgi-plugin-python
#=================================================
# SPECIFIC SETUP UWSGI
#=================================================
ynh_add_uwsgi_service
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@@ -136,17 +142,41 @@ ynh_system_user_create "$app"
#=================================================
# Copy Files
cp ../conf/syncserver.ini "$final_path/syncserver.ini"
ynh_replace_string "__APP__" "$app" "$final_path/syncserver.ini"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/syncserver.ini"
ynh_replace_string "__PATH__" "$path_url" "$final_path/syncserver.ini"
ynh_replace_string "__NAME__" "$app" "$final_path/syncserver.ini"
ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/syncserver.ini"
ynh_replace_string "__SECRET__" "$secret" "$final_path/syncserver.ini"
ynh_replace_string "__APP__" "$app" "$finaluwsgiini"
ynh_replace_string "__DOMAIN__" "$domain" "$finaluwsgiini"
ynh_replace_string "__PATH__" "$path_url" "$finaluwsgiini"
ynh_replace_string "__NAME__" "$app" "$finaluwsgiini"
ynh_replace_string "__FINALPATH__" "$final_path" "$finaluwsgiini"
ynh_replace_string "__SECRET__" "$secret" "$finaluwsgiini"
ynh_replace_string "__DB_USER__" "$db_user" "$finaluwsgiini"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$finaluwsgiini"
ynh_replace_string "__DB_NAME__" "$db_name" "$finaluwsgiini"
rm "$final_path/syncserver.ini"
ln -s "$finaluwsgiini" "$final_path/syncserver.ini"
#=================================================
# pip installation
#=================================================
virtualenv "$final_path/local"
# Init virtualenv
(
set +o nounset
source "$final_path/local/bin/activate"
set -o nounset
cd "$final_path"
pip install --upgrade pip
CFLAGS="-Wno-error -Wno-error=format-security" \
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" \
pip install --requirement "$final_path/requirements.txt"
python "$final_path/setup.py" develop
touch "$final_path/local/COMPLETE"
)
ynh_replace_string "__DB_USER__" "$db_user" "$final_path/syncserver.ini"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/syncserver.ini"
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/syncserver.ini"
#=================================================
# GENERIC FINALIZATION
@@ -162,12 +192,6 @@ ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/syncserver.ini"
ynh_use_logrotate
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add "$app" -l /var/log/$app/$app.log
#=================================================
# SETUP SSOWAT
#=================================================
@@ -178,6 +202,5 @@ ynh_app_setting_set "$app" skipped_uris "/"
# RELOAD NGINX
#=================================================
systemctl stop "$app.service"
systemctl start "$app.service"
systemctl start "uwsgi-app@$app.service"
systemctl reload nginx