This commit is contained in:
2022-12-06 13:15:58 +08:00
parent 17339d3259
commit a0849e40ef
52 changed files with 463 additions and 43 deletions

View File

@@ -7,6 +7,8 @@
# - /var/lib/nginx/html #
# - /var/log/nginx #
# - /var/log/php7 #
# ENV #
# - GLOBAL_DIRECTIVES #
##################################################
set -euo pipefail
@@ -15,6 +17,7 @@ trap Quit EXIT
PIDS=
GOT_SIGTERM=
GLOBAL_DIRECTIVES="${GLOBAL_DIRECTIVES:-user nginx;worker_processes auto;}"
function Print {
local file=/dev/null
@@ -24,6 +27,8 @@ function Print {
function Quit {
local running
Print killing nginx ...
nginx -s quit || true
while running= ; do
pkill -f php-fpm7 && running=1 && Print killing php-fpm7 ...
pkill -f sleep && running=1 && Print killing sleep ...
@@ -35,6 +40,11 @@ function Quit {
test -n "$GOT_SIGTERM"
}
function ChangeOwner {
Print Change file owner ...
chown nginx.root /var/log/nginx/
}
function SideCar {
local day= last_day=$(date +%d)
local md5= last_md5=$(find /etc/nginx/ -type f -name "*.conf" \
@@ -61,7 +71,7 @@ function StartProc {
php-fpm7 -F -y /etc/php7/php-fpm.conf &
PIDS="$PIDS $!"
Print Start nginx ...
nginx -g 'daemon off;pid /run/nginx/nginx.pid;' &
nginx -g "$GLOBAL_DIRECTIVES" &
PIDS="$PIDS $!"
Print Start nginx sidecar ...
SideCar &
@@ -70,6 +80,7 @@ function StartProc {
function Main {
local pid=
ChangeOwner
StartProc
trap "GOT_SIGTERM=1; Print Got SIGTERM ..." SIGTERM
while [ -z "$GOT_SIGTERM" ] && sleep 1; do