Some checks failed
Cloud Apache Container / Build-and-Push (74) (push) Successful in 2m22s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 3m14s
Cloud Apache Container / Build-and-Push (82) (push) Has been cancelled
Cloud Apache Container / Build-and-Push (83) (push) Has been cancelled
Cloud Apache Container / Build-and-Push (84) (push) Has been cancelled
Cloud Apache Container / Build-and-Push (85) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (74) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (80) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (81) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (82) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (83) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (84) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (85) (push) Has been cancelled
Cloud Apache Container / Build-Shared-httpd (push) Has been cancelled
Cloud Apache Container / Build-and-Push (81) (push) Has been cancelled
Separate Apache and PHP-FPM into distinct container roles to reduce per-customer memory overhead on shared servers. Adds three new images: - Dockerfile.fpm: PHP-FPM only (no Apache), listens on TCP port 9000 - Dockerfile.shared-httpd: Apache only (no PHP), with SSL and proxy_fcgi - Existing Dockerfile unchanged for standalone mode Key changes: - detect-memory.sh: CONTAINER_ROLE env var (combined/fpm_only/httpd_only) controls the memory budget split - create-php-config.sh: FPM_LISTEN env var for TCP port vs Unix socket, added /fpm-ping and /fpm-status health endpoints - New entrypoints for each container role - tune-mpm.sh for hot-adjusting Apache MPM settings - shared-vhost-template.tpl with proxy_fcgi and SSL on port 443 - CI/CD builds all three image types in parallel Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
80 lines
3.2 KiB
Bash
Executable File
80 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Hot-adjust Apache MPM Event settings and graceful reload.
|
|
# Usage: tune-mpm.sh [--max-workers N] [--server-limit N] [--start-servers N]
|
|
# [--min-spare-threads N] [--max-spare-threads N]
|
|
# [--max-connections-per-child N]
|
|
|
|
set -euo pipefail
|
|
|
|
# Read current values from the config as defaults
|
|
CONFIG_FILE="/etc/httpd/conf.d/mpm-tuning.conf"
|
|
|
|
if [ ! -f "$CONFIG_FILE" ]; then
|
|
echo "Error: $CONFIG_FILE not found. Run detect-memory.sh first."
|
|
exit 1
|
|
fi
|
|
|
|
# Parse current values from config
|
|
current_start=$(grep -oP 'StartServers\s+\K\d+' "$CONFIG_FILE" 2>/dev/null || echo "1")
|
|
current_min_spare=$(grep -oP 'MinSpareThreads\s+\K\d+' "$CONFIG_FILE" 2>/dev/null || echo "5")
|
|
current_max_spare=$(grep -oP 'MaxSpareThreads\s+\K\d+' "$CONFIG_FILE" 2>/dev/null || echo "15")
|
|
current_max_workers=$(grep -oP 'MaxRequestWorkers\s+\K\d+' "$CONFIG_FILE" 2>/dev/null || echo "50")
|
|
current_server_limit=$(grep -oP 'ServerLimit\s+\K\d+' "$CONFIG_FILE" 2>/dev/null || echo "2")
|
|
current_max_conn=$(grep -oP 'MaxConnectionsPerChild\s+\K\d+' "$CONFIG_FILE" 2>/dev/null || echo "3000")
|
|
|
|
# Parse arguments
|
|
START_SERVERS=$current_start
|
|
MIN_SPARE_THREADS=$current_min_spare
|
|
MAX_SPARE_THREADS=$current_max_spare
|
|
MAX_REQUEST_WORKERS=$current_max_workers
|
|
SERVER_LIMIT=$current_server_limit
|
|
MAX_CONNECTIONS_PER_CHILD=$current_max_conn
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--max-workers) MAX_REQUEST_WORKERS="$2"; shift 2 ;;
|
|
--server-limit) SERVER_LIMIT="$2"; shift 2 ;;
|
|
--start-servers) START_SERVERS="$2"; shift 2 ;;
|
|
--min-spare-threads) MIN_SPARE_THREADS="$2"; shift 2 ;;
|
|
--max-spare-threads) MAX_SPARE_THREADS="$2"; shift 2 ;;
|
|
--max-connections-per-child) MAX_CONNECTIONS_PER_CHILD="$2"; shift 2 ;;
|
|
--help|-h)
|
|
echo "Usage: $0 [--max-workers N] [--server-limit N] [--start-servers N]"
|
|
echo " [--min-spare-threads N] [--max-spare-threads N]"
|
|
echo " [--max-connections-per-child N]"
|
|
echo ""
|
|
echo "Current values:"
|
|
echo " StartServers: $current_start"
|
|
echo " MinSpareThreads: $current_min_spare"
|
|
echo " MaxSpareThreads: $current_max_spare"
|
|
echo " MaxRequestWorkers: $current_max_workers"
|
|
echo " ServerLimit: $current_server_limit"
|
|
echo " MaxConnectionsPerChild: $current_max_conn"
|
|
exit 0
|
|
;;
|
|
*) echo "Unknown option: $1"; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
# Write updated config
|
|
cat <<EOF > "$CONFIG_FILE"
|
|
<IfModule mpm_event_module>
|
|
StartServers ${START_SERVERS}
|
|
MinSpareThreads ${MIN_SPARE_THREADS}
|
|
MaxSpareThreads ${MAX_SPARE_THREADS}
|
|
ThreadLimit 64
|
|
ThreadsPerChild 25
|
|
MaxRequestWorkers ${MAX_REQUEST_WORKERS}
|
|
ServerLimit ${SERVER_LIMIT}
|
|
MaxConnectionsPerChild ${MAX_CONNECTIONS_PER_CHILD}
|
|
</IfModule>
|
|
EOF
|
|
|
|
echo "MPM config updated:"
|
|
echo " StartServers=$START_SERVERS ServerLimit=$SERVER_LIMIT MaxRequestWorkers=$MAX_REQUEST_WORKERS"
|
|
echo " MinSpareThreads=$MIN_SPARE_THREADS MaxSpareThreads=$MAX_SPARE_THREADS MaxConnectionsPerChild=$MAX_CONNECTIONS_PER_CHILD"
|
|
|
|
# Graceful reload
|
|
/usr/sbin/httpd -k graceful
|
|
echo "Apache graceful reload triggered."
|