From d7265028c50ccff9c74545df4f26a881a8440824 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 14 Oct 2018 17:45:28 +0200 Subject: [PATCH] Update to last version and allow multi instance --- check_process | 14 +++++++------- conf/app.src | 4 ++-- conf/nginx.conf | 37 +++++++++---------------------------- manifest.json | 4 ++-- scripts/change_url | 2 +- scripts/install | 15 ++++++++++++--- scripts/remove | 7 ++++--- scripts/restore | 2 +- scripts/upgrade | 19 ++++++++++++++++++- 9 files changed, 56 insertions(+), 48 deletions(-) diff --git a/check_process b/check_process index c598978..044f0aa 100644 --- a/check_process +++ b/check_process @@ -12,11 +12,11 @@ setup_private=0 setup_public=1 upgrade=1 -# upgrade=1 from_commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b + upgrade=1 from_commit=04cb5f0ec18def9d50fa861c16d491275843b9e7 backup_restore=1 - multi_instance=0 + multi_instance=1 incorrect_path=1 - port_already_use=0 + port_already_use=1 (4242) change_url=1 ;;; Levels Level 1=auto @@ -33,7 +33,7 @@ ;;; Options Email= Notification=down -#;;; Upgrade options -# ; commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b -# name=20 Jan 2017 b86b9d09ed97bf04b7e1afad72376d8d695b418b -# manifest_arg=domain=DOMAIN&admin=USER&path=PATH&language=en&is_public=Yes&abiword=0& +;;; Upgrade options + ; commit=04cb5f0ec18def9d50fa861c16d491275843b9e7 + name=03 Sep 2018 04cb5f0ec18def9d50fa861c16d491275843b9e7 + manifest_arg=domain=DOMAIN&path=PATH& diff --git a/conf/app.src b/conf/app.src index 6b7fe1e..2460191 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/YunoHost/yunorunner/archive/5dc2c34a2939c537a539320df2c6882068aa5b64.zip -SOURCE_SUM=454d15c16637ded7d41cfbed3561fff0 +SOURCE_URL=https://github.com/YunoHost/yunorunner/archive/7ce0982ca5bdb94f5fc955ff1612ae82ced4f2d6.zip +SOURCE_SUM=697a7946aaf7d4f5925870a435cb7fbd SOURCE_SUM_PRG=md5sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index a781bee..a34302c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,36 +6,17 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://127.0.0.1:4242/; + proxy_pass http://127.0.0.1:__PORT__/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - -# proxy_set_header Host $host; - -# proxy_set_header X-Real-IP $remote_addr; -# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; -# proxy_set_header X-Forwarded-Proto $scheme; -# proxy_set_header X-NginX-Proxy true; -# proxy_set_header X-Forwarded-User $remote_user; - -# sendfile off; - -# proxy_max_temp_file_size 0; - -# client_max_body_size 10m; -# client_body_buffer_size 128k; - -# proxy_connect_timeout 90; -# proxy_send_timeout 90; -# proxy_read_timeout 90; - -# proxy_buffer_size 4k; -# proxy_buffers 4 32k; -# proxy_busy_buffers_size 64k; -# proxy_temp_file_write_size 64k; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; + + location __PATH__/logs { + alias /home/CI_package_check/logs/; + autoindex on; + } } diff --git a/manifest.json b/manifest.json index 7e6271c..6376cd0 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "CI runner for YunoHost" }, - "version": "1.0~ynh1", + "version": "240918~ynh1", "url": "https://github.com/YunoHost/yunorunner", "license": "free", "maintainer": { @@ -15,7 +15,7 @@ "requirements": { "yunohost": ">= 3.1.0" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], diff --git a/scripts/change_url b/scripts/change_url index bf73d54..2b77032 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME # LOAD SETTINGS #================================================= -# appname=$(ynh_app_setting_get $app appname) +port=$(ynh_app_setting_get $app port) #================================================= # CHECK THE SYNTAX OF THE PATHS diff --git a/scripts/install b/scripts/install index e7cb88f..a87b7d2 100644 --- a/scripts/install +++ b/scripts/install @@ -57,8 +57,10 @@ ynh_app_setting_set $app path $path_url # FIND AND OPEN A PORT #================================================= -# Ouvre le port 4242 dans le firewall -ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP 4242 +port=$(ynh_find_port 4242) +# Ouvre le port dans le firewall +ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port +ynh_app_setting_set $app port $port #================================================= # INSTALL DEPENDENCIES @@ -121,6 +123,13 @@ ve3/bin/pip3 install -r requirements.txt ) ynh_add_systemd_config +#================================================= +# CHANGE PORT IN YUNORUNNER +#================================================= + +ynh_replace_string "localhost:4242" "localhost:$port" "$final_path/ciclic" +ynh_replace_string "port=4242" "port=$port" "$final_path/run.py" + #================================================= # GENERIC FINALISATION #================================================= @@ -152,4 +161,4 @@ ynh_system_reload --service_name=nginx # START YUNORUNNER #================================================= -ynh_system_reload --service_name=yunorunner --action=start +ynh_system_reload --service_name=$app --action=start diff --git a/scripts/remove b/scripts/remove index 0437823..632eb44 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,6 +16,7 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) +port=$(ynh_app_setting_get $app port) #================================================= # STANDARD REMOVE @@ -57,10 +58,10 @@ ynh_remove_nginx_config # Suppression de la configuration nginx # CLOSE A PORT #================================================= -if yunohost firewall list | grep -q "\- 4242$" +if yunohost firewall list | grep -q "\- $port$" then - ynh_print_info "Close port 4242" >&2 - ynh_exec_quiet yunohost firewall disallow TCP 4242 + ynh_print_info "Close port $port" >&2 + ynh_exec_quiet yunohost firewall disallow TCP $port fi #================================================= diff --git a/scripts/restore b/scripts/restore index c9faf28..388aad6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -101,7 +101,7 @@ ynh_system_reload --service_name=nginx # START YUNORUNNER #================================================= -ynh_system_reload --service_name=yunorunner --action=start +ynh_system_reload --service_name=$app --action=start #================================================= # DEACTIVE MAINTENANCE MODE diff --git a/scripts/upgrade b/scripts/upgrade index f9b6791..02285ed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) +port=$(ynh_app_setting_get $app port) #================================================= # CHECK VERSION @@ -29,6 +30,12 @@ upgrade_type=$(ynh_check_app_version_changed) # ENSURE DOWNWARD COMPATIBILITY #================================================= +# If port doesn't exist, create it +if [ -z "$port" ]; then + port=4242 + ynh_app_setting_set $app port $port +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -91,6 +98,16 @@ ynh_system_user_create $app # Create the dedicated user, if not exist ynh_add_systemd_config +#================================================= +# CHANGE PORT IN YUNORUNNER +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_replace_string "localhost:4242" "localhost:$port" "$final_path/ciclic" + ynh_replace_string "port=4242" "port=$port" "$final_path/run.py" +fi + #================================================= # GENERIC FINALISATION #================================================= @@ -117,7 +134,7 @@ ynh_system_reload --service_name=nginx # RESTART YUNORUNNER #================================================= -ynh_system_reload --service_name=yunorunner --action=restart +ynh_system_reload --service_name=$app --action=restart #=================================================