mirror of
https://github.com/devilbox/docker-php-fpm.git
synced 2025-12-10 19:11:16 +00:00
Allow to use supervisorctl to be able to reload PHP configuration without restarting
This commit is contained in:
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -79,7 +79,6 @@ RUN set -eux \
|
||||
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY ./data/docker-entrypoint.d/*.sh /docker-entrypoint.d/
|
||||
COPY ./data/postfix.sh /usr/local/sbin/postfix.sh
|
||||
COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
###
|
||||
|
||||
@@ -9,6 +9,51 @@ set -o pipefail
|
||||
# Functions
|
||||
############################################################
|
||||
|
||||
###
|
||||
### Create main supvervisord configuration file
|
||||
###
|
||||
supervisor_create_config() {
|
||||
local path="${1}"
|
||||
|
||||
# Enable supervisorctl (default: disabled)
|
||||
SVCTL_ENABLE="${SVCTL_ENABLE:-0}"
|
||||
if [ -z "${SVCTL_USER:-}" ]; then
|
||||
SVCTL_USER="$( get_random_alphanum "10" )"
|
||||
fi
|
||||
if [ -z "${SVCTL_PASS:-}" ]; then
|
||||
SVCTL_PASS="$( get_random_alphanum "10" )"
|
||||
fi
|
||||
|
||||
{
|
||||
# Use 'echo_supervisord_conf' to generate an example config
|
||||
if [ "${SVCTL_ENABLE}" = "1" ]; then
|
||||
echo "[rpcinterface:supervisor]"
|
||||
echo "supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface"
|
||||
echo
|
||||
echo "[unix_http_server]"
|
||||
echo "file = /tmp/supervisor.sock"
|
||||
echo "chmod = 0700"
|
||||
echo
|
||||
echo "[supervisorctl]"
|
||||
echo "serverurl = unix:///tmp/supervisor.sock"
|
||||
echo "username = ${SVCTL_USER} ; should be same as in [*_http_server] if set"
|
||||
echo "password = ${SVCTL_PASS} ; should be same as in [*_http_server] if set"
|
||||
fi
|
||||
echo "[supervisord]"
|
||||
echo "user = root"
|
||||
echo "nodaemon = true"
|
||||
echo "loglevel = info"
|
||||
echo "logfile = /var/log/supervisor/supervisord.log"
|
||||
echo "pidfile = /var/run/supervisord.pid"
|
||||
echo "childlogdir = /var/log/supervisor"
|
||||
echo "strip_ansi = true" # Required to fix tail logs
|
||||
echo
|
||||
echo "[include]"
|
||||
echo "files = /etc/supervisor/conf.d/*.conf /etc/supervisor/custom.d/*.conf"
|
||||
} > "${path}"
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
### Add service to supervisord
|
||||
###
|
||||
@@ -49,3 +94,26 @@ supervisor_add_service() {
|
||||
echo "stderr_events_enabled = true";
|
||||
} > "${confd}/${name}.conf"
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
### Get Random alphanumeric string
|
||||
###
|
||||
get_random_alphanum() {
|
||||
local len="${1:-15}" # length defaults to 15
|
||||
tr -dc A-Za-z0-9 < /dev/urandom | head -c "${len}" | xargs || true
|
||||
}
|
||||
|
||||
|
||||
############################################################
|
||||
# Sanity Checks
|
||||
############################################################
|
||||
|
||||
if ! command -v tr >/dev/null 2>&1; then
|
||||
echo "tr not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v xargs >/dev/null 2>&1; then
|
||||
echo "xargs not found, but required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -120,6 +120,12 @@ if ! port_forward_validate "FORWARD_PORTS_TO_LOCALHOST" "${DEBUG_LEVEL}"; then
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Supvervisor: supervisord.conf
|
||||
###
|
||||
supervisor_create_config "/etc/supervisor/supervisord.conf"
|
||||
|
||||
|
||||
###
|
||||
### Supervisor: socat
|
||||
###
|
||||
@@ -185,7 +191,6 @@ execute_custom_scripts "/startup.1.d" "${DEBUG_LEVEL}"
|
||||
execute_custom_scripts "/startup.2.d" "${DEBUG_LEVEL}"
|
||||
|
||||
|
||||
###
|
||||
###
|
||||
### Startup
|
||||
###
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[supervisord]
|
||||
user = root
|
||||
nodaemon = true
|
||||
logfile = /var/log/supervisor/supervisord.log
|
||||
pidfile = /var/run/supervisord.pid
|
||||
childlogdir = /var/log/supervisor
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf /etc/supervisor/custom.d/*.conf
|
||||
@@ -120,6 +120,12 @@ if ! port_forward_validate "FORWARD_PORTS_TO_LOCALHOST" "${DEBUG_LEVEL}"; then
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Supvervisor: supervisord.conf
|
||||
###
|
||||
supervisor_create_config "/etc/supervisor/supervisord.conf"
|
||||
|
||||
|
||||
###
|
||||
### Supervisor: socat
|
||||
###
|
||||
@@ -162,7 +168,7 @@ copy_ini_files "${DVL_PHP_CUST_INI_DIR}" "${DVL_PHP_INI_DIR}" "${DEBUG_LEVEL}"
|
||||
if [ "${PHP_VERSION}" = "5.2" ]; then
|
||||
copy_fpm_5_2_conf_file "${DVL_PHP_CUST_FPM_DIR}/php-fpm.xml" "${DEBUG_LEVEL}"
|
||||
else
|
||||
copy_fpm_files "${DVL_PHP_CUST_FPM_DIR}" "${DVL_PHP_FPM_DIR}" "${DEBUG_LEVEL}"
|
||||
copy_fpm_files "${DVL_PHP_CUST_FPM_DIR}" "${DVL_PHP_FPM_DIR}" "${DEBUG_LEVEL}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user