nginx.upgrade.sh 906 B

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