From aa606b5924772d7437c8b0d1ba2aa8e7e099503c Mon Sep 17 00:00:00 2001 From: Fascinated Date: Fri, 7 Jul 2023 23:43:14 +0100 Subject: [PATCH] add auto restart to nginx and php --- docker/start.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docker/start.sh b/docker/start.sh index 5bd2356..9751857 100644 --- a/docker/start.sh +++ b/docker/start.sh @@ -26,8 +26,15 @@ sed -i "s/^post_max_size = .*/post_max_size = ${MAX_UPLOAD_SIZE}/" /etc/php/8.1/ # Set max upload size for nginx sed -i "s/client_max_body_size 500M;/client_max_body_size ${MAX_UPLOAD_SIZE};/" /etc/nginx/nginx.conf -# Start Nginx -echo "Starting PHP & Nginx" -/etc/init.d/php8.1-fpm start && -chmod 777 /run/php/php8.1-fpm.sock && -nginx -g 'daemon off;' \ No newline at end of file +function start() { + echo "Starting PHP & Nginx" + /etc/init.d/php8.1-fpm start && + chmod 777 /run/php/php8.1-fpm.sock && + nginx -g 'daemon off;' +} + +# Start Nginx and retry if it fails +until start; do + echo "Nginx failed to start, retrying in 5 seconds..." + sleep 5 +done \ No newline at end of file