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

Set unicorn_workers as a variable for the package

This commit is contained in:
Maniack Crudelis 2020-04-28 19:20:16 +02:00
parent 4cb517c7b0
commit 7740c4e505
5 changed files with 26 additions and 20 deletions

View file

@ -32,6 +32,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
#=================================================
# STANDARD BACKUP STEPS

View file

@ -34,6 +34,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -151,11 +152,6 @@ $rake_exec posts:rebake
ynh_print_info --message="Starting a systemd service..."
# Start a systemd service
if [ -n "$(uname -m | grep arm)" ] ; then
unicorn_workers=2
else
unicorn_workers=3
fi
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
#=================================================

View file

@ -312,6 +312,8 @@ else
additional_env=""
unicorn_workers=3
fi
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
ynh_replace_string --match_string="__ADDITIONAL_ENV__" --replace_string="$additional_env" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__LIBJEMALLOC__" --replace_string="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" --target_file="../conf/systemd.service"
ynh_add_systemd_config

View file

@ -144,6 +144,7 @@ if [ -n "$(uname -m | grep arm)" ] ; then
else
unicorn_workers=3
fi
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
#=================================================

View file

@ -24,6 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers)
# Check memory requirements
check_memory_requirements_upgrade
@ -35,6 +36,25 @@ ynh_print_info --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If db_name doesn't exist, create it
if [ -z "$unicorn_workers" ]
then
# We assume for the moment that ARM devices are only dual core, so
# we restrict the number of workers to 2 (the default is 3)
if [ -n "$(uname -m | grep arm)" ]
then
unicorn_workers=2
else
unicorn_workers=3
fi
ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -286,16 +306,7 @@ ynh_print_info --message="Configuring a systemd service..."
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/systemd.service"
# We assume for the moment that ARM devices are only dual core, so
# we restrict the number of workers to 2 (the default is 3)
if [ -n "$(uname -m | grep arm)" ] ; then
additional_env="UNICORN_WORKERS=2"
unicorn_workers=2
else
additional_env=""
unicorn_workers=3
fi
additional_env="UNICORN_WORKERS=$unicorn_workers"
ynh_replace_string --match_string="__ADDITIONAL_ENV__" --replace_string="$additional_env" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__LIBJEMALLOC__" --replace_string="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" --target_file="../conf/systemd.service"
ynh_add_systemd_config
@ -341,11 +352,6 @@ fi
#=================================================
ynh_print_info --message="Starting a systemd service..."
if [ -n "$(uname -m | grep arm)" ] ; then
unicorn_workers=2
else
unicorn_workers=3
fi
# Wait for discourse to be fully started
ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"