Saltstack Official Nginx Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

102 lines
2.2KB

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: nginx
  4. # Required-Start: $local_fs $remote_fs $network $syslog
  5. # Required-Stop: $local_fs $remote_fs $network $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: starts the nginx web server
  9. # Description: starts nginx using start-stop-daemon
  10. ### END INIT INFO
  11. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  12. DAEMON={{ sbin_dir }}/nginx
  13. NAME=nginx
  14. DESC=nginx
  15. # Include nginx defaults if available
  16. if [ -f /etc/default/nginx ]; then
  17. . /etc/default/nginx
  18. fi
  19. test -x $DAEMON || exit 0
  20. set -e
  21. . /lib/lsb/init-functions
  22. test_nginx_config() {
  23. if $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1; then
  24. return 0
  25. else
  26. $DAEMON -t $DAEMON_OPTS
  27. return $?
  28. fi
  29. }
  30. case "$1" in
  31. start)
  32. echo -n "Starting $DESC: "
  33. test_nginx_config
  34. # Check if the ULIMIT is set in /etc/default/nginx
  35. if [ -n "$ULIMIT" ]; then
  36. # Set the ulimits
  37. ulimit $ULIMIT
  38. fi
  39. start-stop-daemon --start --quiet --pidfile {{ pid_path }} \
  40. --exec $DAEMON -- $DAEMON_OPTS || true
  41. echo "$NAME."
  42. ;;
  43. stop)
  44. echo -n "Stopping $DESC: "
  45. start-stop-daemon --stop --quiet --pidfile {{ pid_path }} \
  46. --exec $DAEMON || true
  47. echo "$NAME."
  48. ;;
  49. restart|force-reload)
  50. echo -n "Restarting $DESC: "
  51. start-stop-daemon --stop --quiet --pidfile \
  52. {{ pid_path }} --exec $DAEMON || true
  53. sleep 1
  54. test_nginx_config
  55. # Check if the ULIMIT is set in /etc/default/nginx
  56. if [ -n "$ULIMIT" ]; then
  57. # Set the ulimits
  58. ulimit $ULIMIT
  59. fi
  60. start-stop-daemon --start --quiet --pidfile \
  61. {{ pid_path }} --exec $DAEMON -- $DAEMON_OPTS || true
  62. echo "$NAME."
  63. ;;
  64. reload)
  65. echo -n "Reloading $DESC configuration: "
  66. test_nginx_config
  67. start-stop-daemon --stop --signal HUP --quiet --pidfile {{ pid_path }} \
  68. --exec $DAEMON || true
  69. echo "$NAME."
  70. ;;
  71. configtest|testconfig)
  72. echo -n "Testing $DESC configuration: "
  73. if test_nginx_config; then
  74. echo "$NAME."
  75. else
  76. exit $?
  77. fi
  78. ;;
  79. status)
  80. status_of_proc -p {{ pid_path }} "$DAEMON" nginx && exit 0 || exit $?
  81. ;;
  82. *)
  83. echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
  84. exit 1
  85. ;;
  86. esac
  87. exit 0