#!/bin/sh
# file: nginx/run

exec 2>&1
echo $(realpath $0) started

while true; do
  inotifywait -e close_write,moved_to,create,delete /etc/nginx/conf.d
  sleep 5
  echo "INFO: nginx configuration change detected, attempting to load the new configuration ..."
  nginx -t && nginx -s reload || echo "ERROR: nginx configuration has problems, thus cannot be reloaded."
done &

exec nginx
