From ceff33b76db2d11ac86249a6079002984bdc748a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 24 Mar 2019 21:36:20 +0100 Subject: [PATCH 01/11] Use gitlab-runsvdir --- scripts/_common.sh | 56 ---------------------------------------------- scripts/change_url | 6 ++++- scripts/install | 11 +++++++-- scripts/remove | 10 +++++++++ scripts/restore | 19 +++++++++++----- scripts/upgrade | 13 ++++++++--- 6 files changed, 47 insertions(+), 68 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b1e0a9d..51f079c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -113,62 +113,6 @@ ynh_systemd_action() { fi } -# This function is inspired by the ynh_systemd_action function - -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: gitlab_ctl_waiting [ [-t timeout] ] -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -gitlab_ctl_waiting() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [t]=timeout= ) - local timeout - - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local line_match_new="adopted new unicorn master" - local line_match_existing="adopted existing unicorn master" - local line_match_error="master failed to start" - local log_path="/var/log/gitlab/unicorn/current" - - local timeout=${timeout:-300} - - # Following the starting of the app in its log - local templog="$(mktemp)" - tail -F -n1 "$log_path" >"$templog" & - # get the PID of the tail command - local pid_tail=$! - - if grep --quiet "${line_match_error}" $templog; then # error, so restart gitlab - gitlab-ctl restart - fi - - # Start the timeout and try to find line_match_new or line_match_existing - local i=0 - for i in $(seq 1 $timeout) - do - if grep --quiet "${line_match_new}" "$templog" || grep --quiet "${line_match_existing}" "$templog"; then - ynh_print_info --message="Gitlab has correctly started." - break - fi - if [ $i -ge 3 ]; then - echo -n "." >&2 - fi - sleep 1 - done - if [ $i -ge 3 ]; then - echo "" >&2 - fi - if [ $i -eq $timeout ] - then - ynh_print_warn --message="Gitlab didn't fully started before the timeout." - ynh_print_warn --message="Please find here an extract of the end of the log of Gitlab:" - test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2 - fi - ynh_clean_check_starting -} - # Clean temporary process and file used by ynh_check_starting # (usually used in ynh_clean_setup scripts) # diff --git a/scripts/change_url b/scripts/change_url index f2d9189..aff2950 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -125,9 +125,13 @@ if [ $change_path -eq 1 ]; then gitlab-ctl restart unicorn fi +#================================================= +# WAITING GITLAB +#================================================= ynh_print_info "Waiting for gitlab..." -gitlab_ctl_waiting --timeout=3600 +# Action status to just wait the service +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index bd0f76a..e4715ad 100644 --- a/scripts/install +++ b/scripts/install @@ -182,6 +182,12 @@ gitlab-ctl reconfigure #================================================= # GENERIC FINALIZATION +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log /var/log/$app/gitlab-rails/api_json.log /var/log/$app/gitlab-rails/production.log /var/log/$app/gitlab-rails/production_json.log /var/log/$app/gitlab-rails/sidekiq.log /var/log/$app/unicorn/unicorn_stderr.log /var/log/$app/unicorn/current /var/log/$app/alertmanager/current /var/log/$app/gitaly/current /var/log/$app/gitlab-monitor/current /var/log/$app/gitlab-shell/gitlab-shell.log /var/log/$app/gitlab-workhorse/current /var/log/$app/logrotate/current /var/log/$app/nginx/current /var/log/$app/nginx/access.log /var/log/$app/nginx/error.log /var/log/$app/nginx/gitlab_access.log /var/log/$app/nginx/gitlab_error.log /var/log/$app/node-exporter/current /var/log/$app/postgres-exporter/current /var/log/$app/postgresql/current /var/log/$app/prometheus/current /var/log/$app/redis/current /var/log/$app/redis-exporter/current" + #================================================= # SETUP SSOWAT #================================================= @@ -194,11 +200,12 @@ if [ $is_public -eq 1 ]; then fi #================================================= -# RESTART GITLAB +# WAITING GITLAB #================================================= ynh_print_info "Waiting for gitlab..." -gitlab_ctl_waiting --timeout=3600 +# Action status to just wait the service +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index 6fea6e4..38eca51 100644 --- a/scripts/remove +++ b/scripts/remove @@ -24,6 +24,16 @@ config_path=$(ynh_app_setting_get $app config_path) #================================================= # STANDARD REMOVE +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +if yunohost service status "gitlab-runsvdir" >/dev/null 2>&1 +then + ynh_print_info "Removing $app service" + yunohost service remove "gitlab-runsvdir" +fi + #================================================= # STOP GITLAB #================================================= diff --git a/scripts/restore b/scripts/restore index efa442c..4fc8e06 100644 --- a/scripts/restore +++ b/scripts/restore @@ -122,14 +122,21 @@ ynh_exec_warn_less gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_back gitlab-rake gitlab:check SANITIZE=true -gitlab-ctl restart - -ynh_print_info "Waiting for gitlab..." - -gitlab_ctl_waiting --timeout=3600 - #================================================= # GENERIC FINALIZATION +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log /var/log/$app/gitlab-rails/api_json.log /var/log/$app/gitlab-rails/production.log /var/log/$app/gitlab-rails/production_json.log /var/log/$app/gitlab-rails/sidekiq.log /var/log/$app/unicorn/unicorn_stderr.log /var/log/$app/unicorn/current /var/log/$app/alertmanager/current /var/log/$app/gitaly/current /var/log/$app/gitlab-monitor/current /var/log/$app/gitlab-shell/gitlab-shell.log /var/log/$app/gitlab-workhorse/current /var/log/$app/logrotate/current /var/log/$app/nginx/current /var/log/$app/nginx/access.log /var/log/$app/nginx/error.log /var/log/$app/nginx/gitlab_access.log /var/log/$app/nginx/gitlab_error.log /var/log/$app/node-exporter/current /var/log/$app/postgres-exporter/current /var/log/$app/postgresql/current /var/log/$app/prometheus/current /var/log/$app/redis/current /var/log/$app/redis-exporter/current" + +#================================================= +# WAITING GITLAB +#================================================= +ynh_print_info "Waiting for gitlab..." + +ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c291efa..b671097 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -197,22 +197,29 @@ ynh_add_nginx_config #================================================= # GENERIC FINALIZATION +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log /var/log/$app/gitlab-rails/api_json.log /var/log/$app/gitlab-rails/production.log /var/log/$app/gitlab-rails/production_json.log /var/log/$app/gitlab-rails/sidekiq.log /var/log/$app/unicorn/unicorn_stderr.log /var/log/$app/unicorn/current /var/log/$app/alertmanager/current /var/log/$app/gitaly/current /var/log/$app/gitlab-monitor/current /var/log/$app/gitlab-shell/gitlab-shell.log /var/log/$app/gitlab-workhorse/current /var/log/$app/logrotate/current /var/log/$app/nginx/current /var/log/$app/nginx/access.log /var/log/$app/nginx/error.log /var/log/$app/nginx/gitlab_access.log /var/log/$app/nginx/gitlab_error.log /var/log/$app/node-exporter/current /var/log/$app/postgres-exporter/current /var/log/$app/postgresql/current /var/log/$app/prometheus/current /var/log/$app/redis/current /var/log/$app/redis-exporter/current" + #================================================= # SETUP SSOWAT #================================================= # If app is public, add url to SSOWat conf as skipped_uris -if [[ $is_public -eq 1 ]]; then +if [ $is_public -eq 1 ]; then # See install script ynh_app_setting_set "$app" unprotected_uris "/" fi #================================================= -# RESTART GITLAB +# WAITING GITLAB #================================================= ynh_print_info "Waiting for gitlab..." -gitlab_ctl_waiting --timeout=3600 +# Action status to just wait the service +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 #================================================= # RELOAD NGINX From 00f44915cd73a135906e94fed3719633ae9aaec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 24 Mar 2019 21:50:03 +0100 Subject: [PATCH 02/11] Avoid warning --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 38eca51..f934076 100644 --- a/scripts/remove +++ b/scripts/remove @@ -96,7 +96,7 @@ fi ynh_secure_remove "/var/opt/$app" # Remove the log files -ynh_secure_remove "/var/log/$app/" +ynh_secure_remove "/var/log/$app" #================================================= # END OF SCRIPT From cb8efc39c4d03f973e3516bdbdc3337519b5efca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 24 Mar 2019 22:08:04 +0100 Subject: [PATCH 03/11] Don't wait gitlab during the install --- scripts/install | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/install b/scripts/install index e4715ad..cb2d52e 100644 --- a/scripts/install +++ b/scripts/install @@ -199,14 +199,6 @@ if [ $is_public -eq 1 ]; then ynh_app_setting_set $app unprotected_uris "/" fi -#================================================= -# WAITING GITLAB -#================================================= -ynh_print_info "Waiting for gitlab..." - -# Action status to just wait the service -ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 - #================================================= # RELOAD NGINX #================================================= From 0c7e103e4b8b3fea6ac15d5b9cac0e463603c751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 24 Mar 2019 22:08:13 +0100 Subject: [PATCH 04/11] Wait after the upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index b671097..d81cf68 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -219,7 +219,7 @@ fi ynh_print_info "Waiting for gitlab..." # Action status to just wait the service -ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 #================================================= # RELOAD NGINX From 1d05160c2fc3461b436e32fe18b05d17690bfe49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 25 Mar 2019 01:19:04 +0100 Subject: [PATCH 05/11] line_match for the restore and change_url scripts --- scripts/change_url | 2 +- scripts/restore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index aff2950..300d985 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -131,7 +131,7 @@ fi ynh_print_info "Waiting for gitlab..." # Action status to just wait the service -ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 #================================================= # GENERIC FINALISATION diff --git a/scripts/restore b/scripts/restore index 4fc8e06..bf1e91f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -135,7 +135,7 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica #================================================= ynh_print_info "Waiting for gitlab..." -ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --timeout=3600 +ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 #================================================= # RELOAD NGINX From 6040d6fead1e4385a4368722357fed408f212105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 25 Mar 2019 01:36:16 +0100 Subject: [PATCH 06/11] line_match new key word --- scripts/change_url | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 300d985..8cbd2d5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -131,7 +131,7 @@ fi ynh_print_info "Waiting for gitlab..." # Action status to just wait the service -ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600 #================================================= # GENERIC FINALISATION diff --git a/scripts/restore b/scripts/restore index bf1e91f..2ea09f3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -135,7 +135,7 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica #================================================= ynh_print_info "Waiting for gitlab..." -ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 +ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600 #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index d81cf68..674fc93 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -219,7 +219,7 @@ fi ynh_print_info "Waiting for gitlab..." # Action status to just wait the service -ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600 #================================================= # RELOAD NGINX From 2983d5df6fa16316338a399a6297baec76d00280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Mon, 25 Mar 2019 01:36:16 +0100 Subject: [PATCH 07/11] new line_match key word --- scripts/change_url | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 300d985..8cbd2d5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -131,7 +131,7 @@ fi ynh_print_info "Waiting for gitlab..." # Action status to just wait the service -ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600 #================================================= # GENERIC FINALISATION diff --git a/scripts/restore b/scripts/restore index bf1e91f..2ea09f3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -135,7 +135,7 @@ yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/applica #================================================= ynh_print_info "Waiting for gitlab..." -ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 +ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600 #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index d81cf68..674fc93 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -219,7 +219,7 @@ fi ynh_print_info "Waiting for gitlab..." # Action status to just wait the service -ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="unicorn master" --timeout=3600 +ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600 #================================================= # RELOAD NGINX From 46beac463b9c07599c836052cd0bb2edcdebeab4 Mon Sep 17 00:00:00 2001 From: Kayou Date: Mon, 25 Mar 2019 10:50:51 +0100 Subject: [PATCH 08/11] Update pull_request_template.md --- pull_request_template.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index c589fe5..fc579fa 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -17,7 +17,6 @@ - [ ] **Approval (LGTM)** *Code review and approval have to be from a member of @YunoHost/apps group* - **CI succeeded** : -[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/gitlab_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/gitlab_ynh%20-BRANCH-/) -*Please replace '-BRANCH-' in this link by the name of the branch used.* -*If the PR is from a forked repository. Please provide public results from package_check.* +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/gitlab_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/gitlab_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From d260a5994141dff026831f6d9a2a32606028fca3 Mon Sep 17 00:00:00 2001 From: Kayou Date: Mon, 25 Mar 2019 23:33:21 +0100 Subject: [PATCH 09/11] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 797bd2b..267518b 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name": "Gitlab", "id": "gitlab", "packaging_format": 1, - "version": "11.9.0~ynh1", + "version": "11.9.0~ynh2", "description": { "en": "GitLab is a Git-repository manager.", "fr": "GitLab est un gestionnaire de dépôts Git." From 8108dd38e870fd096036aa6078e7cee28258431b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 27 Mar 2019 10:40:27 +0100 Subject: [PATCH 10/11] Upgrade gitlab to 11.9.1 --- README.md | 2 +- manifest.json | 2 +- scripts/upgrade.d/upgrade.11.9.0.sh | 7 +++++++ scripts/upgrade.d/upgrade.last.sh | 6 +++--- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 scripts/upgrade.d/upgrade.11.9.0.sh diff --git a/README.md b/README.md index feb4765..8349d2d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to GitLab is a web-based Git-repository manager providing wiki, issue-tracking and CI/CD pipeline features, using an open-source license, developed by GitLab Inc. -**Shipped version:** 11.9.0 +**Shipped version:** 11.9.1 ## Screenshots diff --git a/manifest.json b/manifest.json index 267518b..184d450 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name": "Gitlab", "id": "gitlab", "packaging_format": 1, - "version": "11.9.0~ynh2", + "version": "11.9.1~ynh1", "description": { "en": "GitLab is a Git-repository manager.", "fr": "GitLab est un gestionnaire de dépôts Git." diff --git a/scripts/upgrade.d/upgrade.11.9.0.sh b/scripts/upgrade.d/upgrade.11.9.0.sh new file mode 100644 index 0000000..efc07d1 --- /dev/null +++ b/scripts/upgrade.d/upgrade.11.9.0.sh @@ -0,0 +1,7 @@ +gitlab_version="11.9.0" + +gitlab_x86_64_source_sha256="13dcff613c9f7a915117aec8d788e99ac4742e1ac7be0c7c6a87fc8de8f4275d" + +gitlab_arm_source_sha256="2aec5d04f05cc3bb2fa22e52232e4e0841e58fb3f77052f776292db09e2fcf87" + +gitlab_filename="gitlab-ce-${gitlab_version}.deb" diff --git a/scripts/upgrade.d/upgrade.last.sh b/scripts/upgrade.d/upgrade.last.sh index efc07d1..7101850 100644 --- a/scripts/upgrade.d/upgrade.last.sh +++ b/scripts/upgrade.d/upgrade.last.sh @@ -1,7 +1,7 @@ -gitlab_version="11.9.0" +gitlab_version="11.9.1" -gitlab_x86_64_source_sha256="13dcff613c9f7a915117aec8d788e99ac4742e1ac7be0c7c6a87fc8de8f4275d" +gitlab_x86_64_source_sha256="9668345176be07f1f8637b3c72ffea6f8fe2e76a8c5b10b74a340b9b6b97788c" -gitlab_arm_source_sha256="2aec5d04f05cc3bb2fa22e52232e4e0841e58fb3f77052f776292db09e2fcf87" +gitlab_arm_source_sha256="df1fb5be8ec089a77cfe8276cbaabe0e40b0f3368cafc07de984d7795252ee21" gitlab_filename="gitlab-ce-${gitlab_version}.deb" From 923138aa975dad2e97731b570fc48b71b2e7a65b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 27 Mar 2019 17:54:04 +0100 Subject: [PATCH 11/11] worker_processes according to the doc --- conf/gitlab.rb | 3 ++- scripts/change_url | 2 ++ scripts/install | 14 ++++++++++++++ scripts/upgrade | 17 +++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/conf/gitlab.rb b/conf/gitlab.rb index 019281e..7cf8018 100644 --- a/conf/gitlab.rb +++ b/conf/gitlab.rb @@ -23,6 +23,7 @@ nginx['listen_addresses'] = ["0.0.0.0", "[::]"] # listen on all IPv4 and IPv6 ad unicorn['port'] = __PORTUNICORN__ -unicorn['worker_processes'] = 2 +# https://docs.gitlab.com/ee/install/requirements.html#unicorn-workers +unicorn['worker_processes'] = __UNICORN_WORKER_PROCESSES__ sidekiq['concurrency'] = 5 # base: 25 diff --git a/scripts/change_url b/scripts/change_url index 8cbd2d5..56b6737 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,6 +31,7 @@ final_path=$(ynh_app_setting_get $app final_path) config_path=$(ynh_app_setting_get $app config_path) port=$(ynh_app_setting_get "$app" web_port) portUnicorn=$(ynh_app_setting_get "$app" unicorn_port) +unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes) #================================================= # CHECK THE SYNTAX OF THE PATHS @@ -111,6 +112,7 @@ path_url="$new_path" ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb" ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb" ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb" +ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb" ynh_store_file_checksum "$config_path/gitlab.rb" diff --git a/scripts/install b/scripts/install index cb2d52e..d31cbe7 100644 --- a/scripts/install +++ b/scripts/install @@ -54,6 +54,18 @@ else your hardware and the result of the command \"uname -m\"." 1 fi +# https://docs.gitlab.com/ee/install/requirements.html#unicorn-workers +unicorn_worker_processes=$(($(nproc) + 1 )) + +# If the server has at least 2GB of RAM +if [ $(free -g --si | grep Mem: | awk '{print $2}') -ge 2 ]; then + # Min 3 worker processes + unicorn_worker_processes=$(($unicorn_worker_processes>3?$unicorn_worker_processes:3)) +else + # 2 worker processes + unicorn_worker_processes=2 +fi + path_url=$(ynh_normalize_url_path $path_url) # Register (book) web path @@ -71,6 +83,7 @@ ynh_app_setting_set $app use_web_account $use_web_account ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app config_path $config_path ynh_app_setting_set $app architecture $architecture +ynh_app_setting_set $app unicorn_worker_processes $unicorn_worker_processes #================================================= # STANDARD MODIFICATIONS @@ -108,6 +121,7 @@ cp -f ../conf/gitlab.rb "$config_path/gitlab.rb" ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb" ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb" ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb" +ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb" #================================================= # STORE THE CONFIG FILE CHECKSUM diff --git a/scripts/upgrade b/scripts/upgrade index 674fc93..02778ef 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,6 +28,7 @@ config_path=$(ynh_app_setting_get $app config_path) port=$(ynh_app_setting_get "$app" web_port) portUnicorn=$(ynh_app_setting_get "$app" unicorn_port) architecture=$(ynh_app_setting_get "$app" architecture) +unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -54,6 +55,21 @@ if [ -z "$config_path" ]; then ynh_app_setting_set $app config_path $config_path fi +if [ -z "$unicorn_worker_processes" ]; then + # https://docs.gitlab.com/ee/install/requirements.html#unicorn-workers + unicorn_worker_processes=$(($(nproc) + 1 )) + + # If the server has at least 2GB of RAM + if [ $(free -g --si | grep Mem: | awk '{print $2}') -ge 2 ]; then + # Min 3 worker processes + unicorn_worker_processes=$(($unicorn_worker_processes>3?$unicorn_worker_processes:3)) + else + # 2 worker processes + unicorn_worker_processes=2 + fi + ynh_app_setting_set $app unicorn_worker_processes $unicorn_worker_processes +fi + # If architecture doesn't exist, create it if [ -z "$architecture" ]; then # Detect the system architecture @@ -151,6 +167,7 @@ cp -f ../conf/gitlab.rb "$config_path/gitlab.rb" ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb" ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb" ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb" +ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb" ynh_store_file_checksum "$config_path/gitlab.rb"