50 lines
1.4 KiB
Bash
50 lines
1.4 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
#-----------------------------------------------------------------------------------------------
|
|
# Persistently set PHP-FPM pm.max_children on Unraid
|
|
#-----------------------------------------------------------------------------------------------
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/../common.sh"
|
|
|
|
# Load central config
|
|
load_master_conf
|
|
|
|
# Parse CLI args (supports --dry-run)
|
|
parse_args "$@"
|
|
|
|
# Require root
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo -e "\033[0;31m❌ Please run as root.${RESET}\n"
|
|
exit 1
|
|
fi
|
|
|
|
validate_int PHP_MAX_CHILDREN "$PHP_MAX_CHILDREN"
|
|
|
|
# Functions
|
|
apply_php_max_children() {
|
|
local target="pm.max_children = $PHP_MAX_CHILDREN"
|
|
|
|
if [ "$DRY_RUN" = true ]; then
|
|
echo "[DRY-RUN] Would set PHP-FPM max_children to $PHP_MAX_CHILDREN in $PHP_CONF"
|
|
echo "[DRY-RUN] Would restart PHP-FPM service"
|
|
else
|
|
echo "Applying persistent PHP-FPM max_children = $PHP_MAX_CHILDREN"
|
|
sed -i "s/^pm\.max_children.*/$target/" "$PHP_CONF"
|
|
|
|
# Restart PHP-FPM
|
|
/etc/rc.d/rc.php-fpm restart
|
|
|
|
local current
|
|
current=$(grep -E "^pm\.max_children" "$PHP_CONF")
|
|
logger "Userscript: php-fpm setting applied: $current"
|
|
|
|
echo "PHP-FPM max_children persistently set to: $current"
|
|
echo "PHP-FPM restarted successfully."
|
|
fi
|
|
}
|
|
|
|
# MAIN
|
|
echo "==== PHP-FPM Max Children Script Started: $(date) ===="
|
|
apply_php_max_children |