Skip to content

Commit 366dddf

Browse files
committed
php-fpm healtcheck
1 parent 64a3434 commit 366dddf

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

alpine.fpm.slim.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ENV CFLAGS="-I/usr/src/php"
2222

2323
# tzdata to set the timezones through the environment variables
2424
RUN apk --no-cache add \
25-
tzdata
25+
tzdata \
26+
fcgi
2627

2728
# PHP-EXTENSION-INSTALLER
2829
RUN \

alpine.fpm_nginx.slim.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN apk --no-cache add \
2626
tzdata \
2727
supervisor \
2828
nginx \
29+
fcgi \
2930
; \
3031
#mkdir -p /run/nginx ; \
3132
mkdir -p /etc/ssl/nginx ; \

debian.apache.slim.Dockerfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ ENV TERM=xterm
2323
ENV CFLAGS="-I/usr/src/php"
2424

2525
# TOOLS
26-
#RUN apt-get update; \
27-
# apt-get install -y --no-install-recommends \
28-
# curl \
29-
# wget \
30-
# #git \
31-
# #zip unzip \
32-
# #patch \
33-
# #netcat-openbsd \
34-
# ; \
35-
# rm -rf /var/lib/apt/lists/*
26+
RUN apt-get update; \
27+
apt-get install -y --no-install-recommends \
28+
#curl \
29+
wget \
30+
#unzip \
31+
#patch \
32+
netcat-openbsd \
33+
libfcgi-bin \
34+
; \
35+
rm -rf /var/lib/apt/lists/*
3636

3737
# PHP-EXTENSION-INSTALLER
3838
RUN \

debian.fpm.slim.Dockerfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ ENV TERM=xterm
2323
ENV CFLAGS="-I/usr/src/php"
2424

2525
# TOOLS
26-
#RUN apt-get update; \
27-
# apt-get install -y --no-install-recommends \
28-
# curl \
29-
# wget \
30-
# #git \
31-
# #zip unzip \
32-
# #patch \
33-
# #netcat-openbsd \
34-
# ; \
35-
# rm -rf /var/lib/apt/lists/*
26+
RUN apt-get update; \
27+
apt-get install -y --no-install-recommends \
28+
#curl \
29+
wget \
30+
#unzip \
31+
#patch \
32+
netcat-openbsd \
33+
libfcgi-bin \
34+
; \
35+
rm -rf /var/lib/apt/lists/*
3636

3737
# PHP-EXTENSION-INSTALLER
3838
RUN \

entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,26 @@ fi
151151
# Status/Ping
152152
if [ "$PHP_FPM_IS_EXISTS" -eq "1" -a "$ENABLE_PHP_FPM_STATUS" -eq "1" ]; then
153153
echo ">> enabling php-fpm status!"
154+
155+
PHP_FPM_PING_RESPONSE="pong"
156+
154157
cat > ${PHP_FPM_CONF_DIR_PATH}/y-status.conf <<EOF
155158
[www]
156-
; status page (example: http://localhost:${PHP_FPM_STATUS_PORT}${PHP_FPM_STATUS_PATH}?json&full)
159+
; status page
157160
pm.status_path = ${PHP_FPM_STATUS_PATH}
158161
pm.status_listen = ${PHP_FPM_STATUS_PORT}
159162
; ping (healtcheck)
160163
ping.path = ${PHP_FPM_PING_PATH}
161-
;ping.response = pong
164+
;ping.response = ${PHP_FPM_PING_RESPONSE}
162165
EOF
163166

167+
echo ">> ... and create php-fpm-healthcheck.sh"
168+
cat > /usr/local/bin/php-fpm-healthcheck.sh <<EOF
169+
#!/bin/sh
170+
# required: fcgi (alpine) or libfcgi-bin (debian)
171+
SCRIPT_NAME="${PHP_FPM_PING_PATH}" SCRIPT_FILENAME="${PHP_FPM_PING_PATH}" REQUEST_METHOD=GET cgi-fcgi -bind -connect "127.0.0.1:${PHP_FPM_STATUS_PORT}" | grep ${PHP_FPM_PING_RESPONSE}
172+
EOF
173+
chmod +x /usr/local/bin/php-fpm-healthcheck.sh
164174
fi
165175

166176
# Settings (Log, ...)
@@ -169,7 +179,6 @@ if [ "$PHP_FPM_IS_EXISTS" -eq "1" ]; then
169179
[www]
170180
access.format = "%R - %u %t \"%m %r%Q%q\" %s"
171181
EOF
172-
173182
fi
174183

175184
####################################################

0 commit comments

Comments
 (0)