nginx.check-reload.sh 646 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. #
  3. # Legacy action script to visually check if nginx fails to reload
  4. # Source function library.
  5. [ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
  6. prog=nginx
  7. pidfile=`/usr/bin/systemctl show -p PIDFile nginx.service | sed 's/^PIDFile=//' | tr ' ' '\n'`
  8. CHECKSLEEP=3
  9. templog=`/bin/mktemp --tmpdir nginx-check-reload-XXXXXX.log`
  10. trap '/bin/rm -f $templog' 0
  11. /usr/bin/tail --pid=$$ -n 0 --follow=name /var/log/nginx/error.log > $templog &
  12. /bin/sleep 1
  13. /bin/echo -n $"Sending reload signal to $prog: "
  14. killproc -p ${pidfile} ${prog} -HUP
  15. /bin/echo
  16. /bin/sleep $CHECKSLEEP
  17. /bin/grep -E "\[emerg\]|\[alert\]" $templog
  18. exit 0