From db2d03893c45e7b5cddf935f64b326e7e90206fa Mon Sep 17 00:00:00 2001 From: Matthew Baggett Date: Sat, 9 Nov 2019 01:13:01 +0100 Subject: [PATCH] Rejig nginx & php-fpm runits --- Dockerfile | 10 +++++++++- php+nginx/logs-nginx-access.runit | 2 ++ php+nginx/logs-nginx-error.runit | 2 ++ php+nginx/logs-phpfpm-error.runit | 6 ++++++ php+nginx/nginx.runit | 7 +------ php+nginx/php-fpm.runit | 8 ++------ 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 php+nginx/logs-nginx-access.runit create mode 100644 php+nginx/logs-nginx-error.runit create mode 100644 php+nginx/logs-phpfpm-error.runit diff --git a/Dockerfile b/Dockerfile index 742207a..2b83f99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -117,8 +117,14 @@ RUN apt-get -qq update && \ mv /conf/NginxDefault /etc/nginx/sites-enabled/default && \ mkdir /etc/service/nginx && \ mkdir /etc/service/php-fpm && \ + mkdir /etc/service/logs-nginx-access && \ + mkdir /etc/service/logs-nginx-error && \ + mkdir /etc/service/logs-phpfpm-error && \ mv /conf/nginx.runit /etc/service/nginx/run && \ mv /conf/php-fpm.runit /etc/service/php-fpm/run && \ + mv /conf/logs-nginx-access.runit /etc/service/logs-nginx-access/run && \ + mv /conf/logs-nginx-error.runit /etc/service/logs-nginx-error/run && \ + mv /conf/logs-phpfpm-error.runit /etc/service/logs-phpfpm-error/run && \ chmod +x /etc/service/*/run && \ rm -R /conf && \ sed -i "s/{{PHP}}/$PHP_VERSION/g" /etc/nginx/sites-enabled/default && \ @@ -126,7 +132,9 @@ RUN apt-get -qq update && \ # Enable status panel sed -i -e "s|;pm.status_path|pm.status_path|g" /etc/php/*/fpm/pool.d/www.conf && \ # Using environment variables in config files works, it would seem. Neat! - sed -i -e "s|pm.max_children = 5|pm.max_children = \${PHPFPM_MAX_CHILDREN}|g" /etc/php/*/fpm/pool.d/www.conf + sed -i -e "s|pm.max_children = 5|pm.max_children = \${PHPFPM_MAX_CHILDREN}|g" /etc/php/*/fpm/pool.d/www.conf && \ + # Disable daemonising in nginx + sed -i '1s;^;daemon off\;\n;' /etc/nginx/nginx.conf # Expose ports. EXPOSE 80 diff --git a/php+nginx/logs-nginx-access.runit b/php+nginx/logs-nginx-access.runit new file mode 100644 index 0000000..818531a --- /dev/null +++ b/php+nginx/logs-nginx-access.runit @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +tail -f /var/log/nginx/access.log | sed --unbuffered 's|.*\[.*\] |[NGINX] |g' | grep -v /v1/ping \ No newline at end of file diff --git a/php+nginx/logs-nginx-error.runit b/php+nginx/logs-nginx-error.runit new file mode 100644 index 0000000..e7e6f0a --- /dev/null +++ b/php+nginx/logs-nginx-error.runit @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +tail -f /var/log/nginx/error.log \ No newline at end of file diff --git a/php+nginx/logs-phpfpm-error.runit b/php+nginx/logs-phpfpm-error.runit new file mode 100644 index 0000000..479411a --- /dev/null +++ b/php+nginx/logs-phpfpm-error.runit @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +if [[ -f /var/log/php*-fpm.log ]]; then + tail -f /var/log/php*-fpm.log +else + sleep 1 +fi \ No newline at end of file diff --git a/php+nginx/nginx.runit b/php+nginx/nginx.runit index 863f125..bba5fb0 100755 --- a/php+nginx/nginx.runit +++ b/php+nginx/nginx.runit @@ -1,8 +1,3 @@ -#!/bin/bash - -sleep 3; +#!/usr/bin/env bash /usr/sbin/nginx -sleep 3; -tail -f /var/log/nginx/error.log & -tail -f /var/log/nginx/access.log | sed --unbuffered 's|.*\[.*\] |[NGINX] |g' | grep -v /v1/ping diff --git a/php+nginx/php-fpm.runit b/php+nginx/php-fpm.runit index 93ac6b4..31bb670 100755 --- a/php+nginx/php-fpm.runit +++ b/php+nginx/php-fpm.runit @@ -1,9 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash -sleep 3; env | sed "s/\(.*\)=\(.*\)/env[\1]='\2'/" > /etc/php/{{PHP}}/fpm/conf.d/env.conf -cat /etc/php/{{PHP}}/fpm/conf.d/env.conf -/usr/sbin/php-fpm{{PHP}} -sleep 3; -tail -f /var/log/php*-fpm.log +/usr/sbin/php-fpm{{PHP}} -F -R