From 4107c116518a76465b7f5d748c5f84c67df9c9a3 Mon Sep 17 00:00:00 2001 From: pierre Date: Fri, 13 Mar 2026 10:49:44 +0000 Subject: [PATCH] trying different inotifywait command --- Nginx.kube.yaml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Nginx.kube.yaml b/Nginx.kube.yaml index 71b5002..c9d2749 100644 --- a/Nginx.kube.yaml +++ b/Nginx.kube.yaml @@ -63,13 +63,23 @@ spec: command: ["/bin/sh", "-c"] args: - | - apk add --no-cache inotify-tools; - echo "Watcher started..." - while inotifywait -e close_write /etc/nginx/blacklisted.d/blacklisted-sessions.conf; do - echo "Change detected in deny.conf, reloading Nginx..." - # Find the Nginx master process and send SIGHUP (reload) - pkill -HUP nginx - done + + apk add --no-cache inotify-tools; + # Ensure file exists so inotify doesn't fail + touch /etc/nginx/blacklisted.d/blacklisted-sessions.conf; + echo "Watcher started on /etc/nginx/blacklisted.d/blacklisted-sessions.conf" + + while inotifywait -e modify /etc/nginx/blacklisted.d/blacklisted-sessions.conf; do + echo "Change detected, waiting 5 seconds to batch updates..." + sleep 5; + + # Check if Nginx is actually running before signaling + if pgrep nginx > /dev/null; then + echo "Reloading Nginx..." + pkill -HUP nginx + fi + done + volumeMounts: - name: blacklisted-memory-volume mountPath: /etc/nginx/blacklisted.d/