nginx.upgrade.sh 822 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. #
  3. # Legacy action script for "service nginx upgrade"
  4. if [ -f /etc/sysconfig/nginx ]; then
  5. . /etc/sysconfig/nginx
  6. fi
  7. prog=nginx
  8. nginx=/usr/sbin/nginx
  9. conffile=/etc/nginx/nginx.conf
  10. pidfile=`/usr/bin/systemctl show -p PIDFile nginx.service | sed 's/^PIDFile=//' | tr ' ' '\n'`
  11. SLEEPSEC=${SLEEPSEC:-1}
  12. UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS:-5}
  13. oldbinpidfile=${pidfile}.oldbin
  14. ${nginx} -t -c ${conffile} -q || return 6
  15. echo -n $"Starting new master $prog: "
  16. pkill -F ${pidfile} ${prog} --signal USR2
  17. echo
  18. for i in `/usr/bin/seq $UPGRADEWAITLOOPS`; do
  19. /bin/sleep $SLEEPSEC
  20. if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then
  21. echo -n $"Graceful shutdown of old $prog: "
  22. pkill -F ${oldbinpidfile} ${prog} --signal QUIT
  23. echo
  24. exit 0
  25. fi
  26. done
  27. echo $"Upgrade failed!"
  28. exit 1