From 369aa59dc8597085981a44c8dce8f42331eceb05 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 12 May 2018 12:21:31 +0200 Subject: [PATCH] Enable multi-instance and set requirements >=3.0 --- check_process | 2 +- conf/nginx.conf | 2 +- manifest.json | 4 ++-- scripts/install | 2 +- scripts/remove | 3 +++ scripts/upgrade | 17 ++++++++++++++++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/check_process b/check_process index 174f75b..bae967b 100644 --- a/check_process +++ b/check_process @@ -18,7 +18,7 @@ setup_public=1 upgrade=1 backup_restore=1 - multi_instance=0 + multi_instance=1 incorrect_path=0 port_already_use=0 change_url=0 diff --git a/conf/nginx.conf b/conf/nginx.conf index 202ed07..064826f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -66,7 +66,7 @@ location /api/v1/trackfiles/transcode/ { set $cleaned_args $1$2; } proxy_cache_key "$scheme$request_method$host$uri$is_args$cleaned_args"; - proxy_cache transcode; + proxy_cache __NAME__-transcode; proxy_cache_valid 200 7d; proxy_ignore_headers "Set-Cookie"; proxy_hide_header "Set-Cookie"; diff --git a/manifest.json b/manifest.json index 7de2d34..ef153b1 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "funkwhale", "packaging_format": 1, "requirements": { - "yunohost": ">= 2.7.12" + "yunohost": ">= 3.0.0~beta1.2" }, "description": { "en": "A translation platform using Git and Python" @@ -15,7 +15,7 @@ "name": "Jean-Baptiste Holcroft", "email": "jean-baptiste@holcroft.fr" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], diff --git a/scripts/install b/scripts/install index cafc534..760e485 100644 --- a/scripts/install +++ b/scripts/install @@ -114,7 +114,7 @@ ynh_setup_source "$final_path" "app-frontend" # add proxy_cache and connection_upgrade at the beginning of the domain configuration echo " -proxy_cache_path /tmp/$app-transcode levels=1:2 keys_zone=transcode:10m max_size=1g inactive=7d; +proxy_cache_path /tmp/$app-transcode levels=1:2 keys_zone=$app-transcode:10m max_size=1g inactive=7d; # required for websocket support map \$http_upgrade \$connection_upgrade { diff --git a/scripts/remove b/scripts/remove index 2410543..07f9c84 100644 --- a/scripts/remove +++ b/scripts/remove @@ -74,6 +74,9 @@ mv "/etc/nginx/conf.d/$domain.conf.temp" "/etc/nginx/conf.d/$domain.conf" # Remove the dedicated nginx config ynh_remove_nginx_config +# remove local nginx cache +ynh_secure_remove "/tmp/$app-transcode" + #================================================= # CLOSE A PORT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8506de9..c91549f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,7 +70,22 @@ ynh_setup_source "$final_path" "app-frontend" # NGINX CONFIGURATION #================================================= -# there is no need to change the global configuration yet +# change the global configuration +# remove domain specific configuration +tail -n +11 "/etc/nginx/conf.d/$domain.conf" > "/etc/nginx/conf.d/$domain.conf.temp" +mv "/etc/nginx/conf.d/$domain.conf.temp" "/etc/nginx/conf.d/$domain.conf" + +# add proxy_cache and connection_upgrade at the beginning of the domain configuration +echo " + +proxy_cache_path /tmp/$app-transcode levels=1:2 keys_zone=$app-transcode:10m max_size=1g inactive=7d; + +# required for websocket support +map \$http_upgrade \$connection_upgrade { + default upgrade; + '' close; +} +" | cat - "/etc/nginx/conf.d/$domain.conf" > temp && mv temp "/etc/nginx/conf.d/$domain.conf" # Create a dedicated nginx config ynh_add_nginx_config