From 0174f92354da20933b556c0512e186552b629d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Mon, 7 Dec 2020 16:26:56 +0100 Subject: [PATCH] Symplify nginx config and standardize start systemd action --- conf/nginx.conf | 4 ++-- scripts/install | 19 ++++++++++--------- scripts/restore | 6 ++++-- scripts/upgrade | 16 +++++++++------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 27ad038..460eb29 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -12,7 +12,7 @@ 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; + __IS_SUBPATH__uwsgi_param SCRIPT_NAME __PATH__; + __IS_SUBPATH__uwsgi_modifier1 30; uwsgi_pass unix:///run/__NAME__/app.socket; } diff --git a/scripts/install b/scripts/install index 0a44266..0ba638a 100644 --- a/scripts/install +++ b/scripts/install @@ -81,17 +81,15 @@ install_sources # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring nginx" -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 --match_string "uwsgi_param " --replace_string "#uwsgi_param " --target_file "$finalnginxconf" - ynh_replace_string --match_string "uwsgi_modifier1 " --replace_string "#uwsgi_modifier1 " --target_file "$finalnginxconf" + is_subpath="# " +else + is_subpath=" " fi -ynh_store_file_checksum --file "$finalnginxconf" -systemctl reload nginx +ynh_add_nginx_config 'is_subpath' #================================================= # CREATE DEDICATED USER @@ -138,12 +136,15 @@ ynh_script_progression --message="Configuring permissions" ynh_app_setting_set --app=$app --key=skipped_uris --value="/" #================================================= -# RELOAD NGINX +# RELOAD Services #================================================= -ynh_script_progression --message="Reloading nginx web server..." - +ynh_script_progression --message="Restart services..." ynh_systemd_action --service_name=nginx --action=reload +ynh_script_progression --message="Starting $app services..." --weight=3 +ynh_systemd_action --service_name "uwsgi-app@$app.service" \ + --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 3e5612e..29fa948 100644 --- a/scripts/restore +++ b/scripts/restore @@ -94,7 +94,9 @@ systemctl enable "uwsgi-app@$app" --quiet # RELOAD NGINX AND UWSGI #================================================= -systemctl start "uwsgi-app@$app" -systemctl reload nginx +ynh_script_progression --message="Starting pgadmin services..." --weight=3 +ynh_systemd_action --service_name "uwsgi-app@$app.service" \ + --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" +ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 910bf16..69a52c1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -110,18 +110,16 @@ install_sources #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx..." -ynh_add_nginx_config - +ynh_script_progression --message="Configuring nginx" 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" + is_subpath="# " +else + is_subpath=" " fi -ynh_store_file_checksum --file "$finalnginxconf" -systemctl reload nginx +ynh_add_nginx_config 'is_subpath' #================================================= # CREATE DEDICATED USER @@ -162,6 +160,10 @@ set_permissions ynh_app_setting_set --app=$app --key=skipped_uris --value="/" +ynh_script_progression --message="Restarting $app services..." --weight=3 +ynh_systemd_action --service_name "uwsgi-app@$app.service" \ + --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" + #================================================= # END OF SCRIPT #=================================================