mirror of
https://github.com/YunoHost/example_ynh.git
synced 2024-09-03 20:06:13 +02:00
enh php usage in the example
1. add "extra_php-fpm.conf" 2. harmonize "ynh_add_fpm_config" by using "fpm_footprint" variables
This commit is contained in:
parent
f145eaeb16
commit
f369697838
3 changed files with 41 additions and 3 deletions
|
@ -170,7 +170,9 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
|||
|
||||
### `ynh_add_fpm_config` is used to set up a PHP config.
|
||||
### You can remove it if your app doesn't use PHP.
|
||||
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf
|
||||
### `ynh_add_fpm_config` will create a 'config' then add 'extra_php-fpm.conf'
|
||||
### It can use be overwritten by 'conf/php-fpm.conf' but not by default
|
||||
### See helper code https://github.com/YunoHost/yunohost/blob/dev/helpers/php
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
||||
|
@ -178,9 +180,24 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
|||
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
|
||||
### with the reload at the end of the script.
|
||||
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
|
||||
### - and references to 'fpm_footprint' and 'fpm_usage' in the upgrade script
|
||||
### in sections "LOAD SETTINGS" and "ENSURE DOWNWARD COMPATIBILITY"
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
# default setup: should be fine for most application and in a small server usage
|
||||
fpm_usage=low
|
||||
fpm_footprint=low
|
||||
### to ajust values, if you have more users like in a NGO or small compagny, see:
|
||||
### https://github.com/YunoHost/yunohost/blob/dev/helpers/php#L18-L31
|
||||
### If the app is more ressources consumming too
|
||||
ynh_add_fpm_config --usage="$fpm_usage" --footprint="$fpm_footprint"
|
||||
|
||||
#TODO: should this setup should be done directly by the helper? (which default setting then?)
|
||||
#TODO: or the packager has to decide by its own? (how to decide between 'low' or 'high'?)
|
||||
#TODO: depending of the app, only the packager can decide the 'default setup' IMO and server admin wil change it if needed. Using 'config panel' I guess?
|
||||
### alternative setup if you need to use the specific 'conf/php-fpm.conf' file:
|
||||
### Note that 'conf/extra_php-fpm.conf' will not be used in this scenario!
|
||||
### ynh_add_fpm_config --use_template
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
|
|
@ -36,6 +36,9 @@ db_user=$db_name
|
|||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
|
|
|
@ -23,6 +23,9 @@ admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
@ -101,6 +104,21 @@ if ! ynh_permission_exists --permission="api"; then
|
|||
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
|
||||
fi
|
||||
|
||||
### Use these functions if the package was released
|
||||
### without "php fpm footprint" and you are implementing it
|
||||
### Take values from 'install' script
|
||||
#If fpm_footprint doesn't exist, create it
|
||||
if [ -z "$fpm_footprint" ]; then
|
||||
fpm_footprint=low
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||
fi
|
||||
|
||||
# If fpm_usage doesn't exist, create it
|
||||
if [ -z "$fpm_usage" ]; then
|
||||
fpm_usage=low
|
||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -144,7 +162,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
|
Loading…
Add table
Reference in a new issue