From 7bcec180cdc6b4285930e5bd2ea7ee3fe0863547 Mon Sep 17 00:00:00 2001 From: Patrick Carlo-Hickman Date: Fri, 2 Feb 2024 11:00:38 -0500 Subject: [PATCH] Update startup script to remove stale PHP-FPM pid files. --- setup/resources/wsl/startup.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/setup/resources/wsl/startup.sh b/setup/resources/wsl/startup.sh index 4b85834..90b8c42 100755 --- a/setup/resources/wsl/startup.sh +++ b/setup/resources/wsl/startup.sh @@ -5,6 +5,20 @@ if [[ $(id -u) -ne 0 ]]; then exit 1 fi +# If PHP-FPM wasn't stopped properly, its .pid file will still exist. When +# restarting the service, it will get stuck if a stale .pid file exists. +# Remove the stale existing .pid files so the restart won't get stuck. +for file in `find /opt/phpenv/versions -name "*.pid"` +do + PHPFPM_PID=$(cat $file) + PID_CMD=$(ps -p $PHPFPM_PID -o comm=) + + if [[ "$PID_CMD" != "php-fpm" ]]; then + echo "Removing stale pid file [$file]." + rm -f $file + fi +done + service redis-server restart service mysql restart service apache2 restart