mirror of
https://github.com/YunoHost-Apps/my_webapp_ynh.git
synced 2024-09-03 19:46:26 +02:00
Implement FPM usage and footprint in config panel
This commit is contained in:
parent
ee6a4cf5f8
commit
38e6e12553
3 changed files with 86 additions and 1 deletions
|
@ -27,6 +27,29 @@ name = "My Webapp configuration"
|
||||||
choices = ["none", "7.3", "7.4", "8.0"]
|
choices = ["none", "7.3", "7.4", "8.0"]
|
||||||
default = "none"
|
default = "none"
|
||||||
|
|
||||||
|
[main.php_fpm_config.fpm_footprint]
|
||||||
|
ask = "Memory footprint of the service?"
|
||||||
|
type = "select"
|
||||||
|
choices.low = "Low, <= 20Mb per pool"
|
||||||
|
choices.medium = "Medium, between 20Mb and 40Mb per pool"
|
||||||
|
choices.high = "High, > 40Mb per pool"
|
||||||
|
choices.specific = "Use specific value"
|
||||||
|
default = "low"
|
||||||
|
|
||||||
|
[main.php_fpm_config.fpm_free_footprint]
|
||||||
|
visible = "fpm_footprint == 'specific'"
|
||||||
|
ask = "Memory footprint of the service?"
|
||||||
|
type = "number"
|
||||||
|
default = "0"
|
||||||
|
help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
|
||||||
|
|
||||||
|
[main.php_fpm_config.fpm_usage]
|
||||||
|
ask = "Expected usage of the service?"
|
||||||
|
type = "select"
|
||||||
|
choices = ["low", "medium", "high"]
|
||||||
|
default = "low"
|
||||||
|
help = "low: Personal usage, behind the sso. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding."
|
||||||
|
|
||||||
# TODO: Add protected_path as tags, which are created as permission "label (path)", so admin can protect a specific path
|
# TODO: Add protected_path as tags, which are created as permission "label (path)", so admin can protect a specific path
|
||||||
# [main.permissions]
|
# [main.permissions]
|
||||||
# [main.permissions.proteced_path]
|
# [main.permissions.proteced_path]
|
||||||
|
|
|
@ -19,6 +19,7 @@ final_path=$(ynh_app_setting_get $app final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
|
||||||
|
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
|
|
||||||
|
@ -26,6 +27,29 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
get__fpm_footprint() {
|
||||||
|
# Free footprint value for php-fpm
|
||||||
|
# Check if current_fpm_footprint is an integer
|
||||||
|
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||||
|
then
|
||||||
|
echo "specific"
|
||||||
|
else
|
||||||
|
echo "$current_fpm_footprint"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get__free_footprint() {
|
||||||
|
# Free footprint value for php-fpm
|
||||||
|
# Check if current_fpm_footprint is an integer
|
||||||
|
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||||
|
then
|
||||||
|
# If current_fpm_footprint is an integer, that's a numeric value for the footprint
|
||||||
|
echo "$current_fpm_footprint"
|
||||||
|
else
|
||||||
|
echo "0"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -41,6 +65,20 @@ set__password() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set__fpm_footprint() {
|
||||||
|
if [ "$fpm_footprint" != "specific" ]
|
||||||
|
then
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set__fpm_free_footprint() {
|
||||||
|
if [ "$fpm_footprint" = "specific" ]
|
||||||
|
then
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_free_footprint"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -52,6 +90,21 @@ ynh_app_config_validate() {
|
||||||
then
|
then
|
||||||
ynh_die --message="You need to set a password to enable SFTP"
|
ynh_die --message="You need to set a password to enable SFTP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then
|
||||||
|
# If fpm_footprint is set to 'specific', use $fpm_free_footprint value.
|
||||||
|
if [ "$fpm_footprint" = "specific" ]
|
||||||
|
then
|
||||||
|
fpm_footprint=$fpm_free_footprint
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$fpm_footprint" == "0" ]
|
||||||
|
then
|
||||||
|
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_app_config_apply() {
|
ynh_app_config_apply() {
|
||||||
|
@ -91,6 +144,8 @@ ynh_app_config_apply() {
|
||||||
then
|
then
|
||||||
ynh_system_user_del_group --username=$app --groups="sftp.app"
|
ynh_system_user_del_group --username=$app --groups="sftp.app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_app_config_run $1
|
ynh_app_config_run $1
|
||||||
|
|
|
@ -28,6 +28,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
||||||
|
|
||||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
|
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
|
||||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -79,6 +80,12 @@ if [ -z "$fpm_footprint" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If fpm_free_footprint doesn't exist, create it
|
||||||
|
if [ -z "$fpm_free_footprint" ]; then
|
||||||
|
fpm_free_footprint=0
|
||||||
|
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
||||||
|
fi
|
||||||
|
|
||||||
# If fpm_usage doesn't exist, create it
|
# If fpm_usage doesn't exist, create it
|
||||||
if [ -z "$fpm_usage" ]; then
|
if [ -z "$fpm_usage" ]; then
|
||||||
fpm_usage=low
|
fpm_usage=low
|
||||||
|
|
Loading…
Add table
Reference in a new issue