From 923138aa975dad2e97731b570fc48b71b2e7a65b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 27 Mar 2019 17:54:04 +0100 Subject: [PATCH] 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"