1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gitlab_ynh.git synced 2024-09-03 18:36:35 +02:00

Merge pull request #233 from YunoHost-Apps/remove-old-requirements

remove puma config/create swap only if needed
This commit is contained in:
Kayou 2023-10-27 16:57:07 +02:00 committed by GitHub
commit d6c74b0482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 70 deletions

View file

@ -1190,9 +1190,9 @@ gitlab_rails['gitlab_shell_ssh_port'] = __SSH_PORT__
# puma['enable'] = true # puma['enable'] = true
# puma['ha'] = false # puma['ha'] = false
# puma['worker_timeout'] = 60 # puma['worker_timeout'] = 60
puma['worker_processes'] = __PUMA_WORKER_PROCESSES__ # puma['worker_processes'] = 2
puma['min_threads'] = __PUMA_MIN_THREADS__ # puma['min_threads'] = 4
puma['max_threads'] = __PUMA_MAX_THREADS__ # puma['max_threads'] = 4
### Advanced settings ### Advanced settings
# puma['listen'] = '127.0.0.1' # puma['listen'] = '127.0.0.1'

View file

@ -44,44 +44,17 @@ ynh_app_setting_set --app=$app --key=overwrite_nginx --value="1"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#=================================================
# DEFINE THE NUMBER OF WORKERS USED
#=================================================
total_memory=$(ynh_get_ram --total)
if [ $total_memory -lt 4096 ]; then
#https://docs.gitlab.com/omnibus/settings/puma.html#running-in-memory-constrained-environments
puma_worker_processes=0
else
#https://docs.gitlab.com/ce/install/requirements.html#puma-workers
puma_worker_processes=$(( $(nproc) > 2 ? $(($(nproc) - 1)) : 2 ))
fi
# If the server has less than 2GB of RAM
if [ $(ynh_get_ram --total --ignore_swap) -lt 2048 ]; then
puma_min_threads=1
puma_max_threads=1
else
puma_min_threads=2
puma_max_threads=4
fi
ynh_app_setting_set --app=$app --key=puma_worker_processes --value=$puma_worker_processes
ynh_app_setting_set --app=$app --key=puma_max_threads --value=$puma_max_threads
ynh_app_setting_set --app=$app --key=puma_min_threads --value=$puma_min_threads
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
total_swap=$(ynh_get_ram --total --only_swap) total_ram=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
# https://docs.gitlab.com/ce/install/requirements.html#memory # https://docs.gitlab.com/ce/install/requirements.html#memory
# Need at least 2Go of swap # Need at least 2Go of swap
if [ $total_swap -lt 2048 ]; then if [ $total_ram -lt 4096 ]; then
swap_needed=$((2048 - total_swap)) swap_needed=2048
fi fi
if [ $swap_needed -gt 0 ]; then if [ $swap_needed -gt 0 ]; then

View file

@ -22,13 +22,13 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
total_swap=$(ynh_get_ram --total --only_swap) total_ram=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
# https://docs.gitlab.com/ce/install/requirements.html#memory # https://docs.gitlab.com/ce/install/requirements.html#memory
# Need at least 2Go of swap # Need at least 2Go of swap
if [ $total_swap -lt 2048 ]; then if [ $total_ram -lt 4096 ]; then
swap_needed=$((2048 - total_swap)) swap_needed=2048
fi fi
if [ $swap_needed -gt 0 ]; then if [ $swap_needed -gt 0 ]; then

View file

@ -28,20 +28,19 @@ fi
config_path=/etc/$app config_path=/etc/$app
chmod 755 $install_dir chmod 755 $install_dir
if [ -z "$puma_max_threads" ] || [ -z "$puma_min_threads" ]; then if [ -n $(ynh_app_setting_get --app=$app --key=puma_worker_processes) ]
# If the server has less than 2GB of RAM then
if [ $(ynh_get_ram --total --ignore_swap) -lt 2000 ]; then ynh_app_setting_delete --app=$app --key=puma_worker_processes
puma_min_threads=1 fi
puma_max_threads=1
else
puma_min_threads=2
puma_max_threads=4
fi
ynh_app_setting_set --app=$app --key=puma_max_threads --value=$puma_max_threads if [ -n $(ynh_app_setting_get --app=$app --key=puma_max_threads) ]
ynh_app_setting_set --app=$app --key=puma_min_threads --value=$puma_min_threads then
ynh_app_setting_delete --app=$app --key=puma_max_threads
fi
ynh_app_setting_delete --app=$app --key=unicorn_worker_processes if [ -n $(ynh_app_setting_get --app=$app --key=puma_min_threads) ]
then
ynh_app_setting_delete --app=$app --key=puma_min_threads
fi fi
# If architecture doesn't exist, create it # If architecture doesn't exist, create it
@ -74,33 +73,17 @@ fi
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#=================================================
# DEFINE THE NUMBER OF WORKERS USED
#=================================================
total_memory=$(ynh_get_ram --total)
if [ $total_memory -lt 4096 ]; then
#https://docs.gitlab.com/omnibus/settings/puma.html#running-in-memory-constrained-environments
puma_worker_processes=0
else
#https://docs.gitlab.com/ce/install/requirements.html#puma-workers
puma_worker_processes=$(( $(nproc) > 2 ? $(($(nproc) - 1)) : 2 ))
fi
ynh_app_setting_set --app=$app --key=puma_worker_processes --value=$puma_worker_processes
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
total_swap=$(ynh_get_ram --total --only_swap) total_ram=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
# https://docs.gitlab.com/ce/install/requirements.html#memory # https://docs.gitlab.com/ce/install/requirements.html#memory
# Need at least 2Go of swap # Need at least 2Go of swap
if [ $total_swap -lt 2048 ]; then if [ $total_ram -lt 4096 ]; then
swap_needed=$((2048 - total_swap)) swap_needed=2048
fi fi
if [ $swap_needed -gt 0 ]; then if [ $swap_needed -gt 0 ]; then

View file

@ -128,9 +128,6 @@ EOS"
sed -i "s/# gitlab_rails\['gitlab_shell_ssh_port'\] = 22/gitlab_rails['gitlab_shell_ssh_port'] = __SSH_PORT__/" $conf_file sed -i "s/# gitlab_rails\['gitlab_shell_ssh_port'\] = 22/gitlab_rails['gitlab_shell_ssh_port'] = __SSH_PORT__/" $conf_file
# Change puma settings # Change puma settings
sed -i "s/# puma\['worker_processes'\] = .*/puma['worker_processes'] = __PUMA_WORKER_PROCESSES__/" $conf_file
sed -i "s/# puma\['min_threads'\] = .*/puma['min_threads'] = __PUMA_MIN_THREADS__/" $conf_file
sed -i "s/# puma\['max_threads'\] = .*/puma['max_threads'] = __PUMA_MAX_THREADS__/" $conf_file
sed -i "s/# puma\['port'\] = .*/puma['port'] = __PORT_PUMA__/" $conf_file sed -i "s/# puma\['port'\] = .*/puma['port'] = __PORT_PUMA__/" $conf_file
# Change sidekiq settings # Change sidekiq settings