Skip to content

Commit

Permalink
Merge pull request #1035 from Automattic/update/fpm-runner
Browse files Browse the repository at this point in the history
reafctor(php-fpm): more robust entrypoint script
  • Loading branch information
sjinks authored Dec 30, 2024
2 parents e991d36 + 7bc17c2 commit dddd4d2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions php-fpm/rootfs/usr/local/bin/run.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
#!/bin/sh

if [ "enable" = "$XDEBUG" ]; then
: "${XDEBUG:=disable}"

if [ "enable" = "${XDEBUG}" ]; then
echo "Enabling XDebug"
phpenmod xdebug
else
echo "Disabling XDebug"
phpdismod xdebug
fi

# shellcheck disable=SC2312
if [ -n "${LANDO_INFO}" ] && [ 'null' != "$(echo "${LANDO_INFO}" | jq -r .mailpit)" ]; then
phpenmod mailpit
else
phpdismod mailpit
fi

MY_UID="$(id -u)"
FPM_OPTIONS=""

if [ "${MY_UID}" = "0" ]; then
FPM_OPTIONS="-R"
fi

if [ -n "${ENABLE_CRON}" ]; then
/usr/bin/cron-control-runner -fpm-url tcp://127.0.0.1:9000 -wp-cli-path /usr/local/bin/wp -wp-path /wp -prom-metrics-address :4444 &
PID=$!
# shellcheck disable=SC2064
trap "kill ${PID}" EXIT INT TERM
fi

/usr/sbin/php-fpm
# shellcheck disable=SC2248
/usr/sbin/php-fpm ${FPM_OPTIONS}
else
# shellcheck disable=SC2248
exec /usr/sbin/php-fpm ${FPM_OPTIONS}
fi

0 comments on commit dddd4d2

Please sign in to comment.