You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=80
  4. USE_PROCD=1
  5. NGINX_UTIL="/usr/bin/nginx-util"
  6. eval $("${NGINX_UTIL}" get_env)
  7. start_service() {
  8. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  9. [ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
  10. ${NGINX_UTIL} init_lan
  11. procd_open_instance
  12. NCPUS="$(grep -c '^processor\s*:' /proc/cpuinfo)"
  13. procd_set_param command /usr/sbin/nginx -c "${NGINX_CONF}" \
  14. -g "daemon off; worker_processes $NCPUS;"
  15. procd_set_param stdout 1
  16. procd_set_param stderr 1
  17. procd_set_param file "${LAN_LISTEN}" "${LAN_LISTEN}.default" \
  18. "${NGINX_CONF}" "${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
  19. [ "${LAN_SSL_LISTEN}" == "" ] \
  20. || procd_append_param file "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
  21. "${LAN_SSL_LISTEN}" "${LAN_SSL_LISTEN}.default"
  22. procd_set_param respawn
  23. procd_close_instance
  24. }
  25. stop_service() {
  26. rm -f "${LAN_LISTEN}" "${LAN_LISTEN}.default"
  27. [ "${LAN_SSL_LISTEN}" == "" ] \
  28. || rm -f "${LAN_SSL_LISTEN}" "${LAN_SSL_LISTEN}.default"
  29. }
  30. service_triggers() {
  31. procd_add_reload_interface_trigger loopback
  32. procd_add_reload_interface_trigger lan
  33. }
  34. reload_service() {
  35. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  36. [ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
  37. ${NGINX_UTIL} init_lan
  38. procd_send_signal nginx
  39. }
  40. relog() {
  41. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  42. procd_send_signal nginx '*' USR1
  43. }
  44. EXTRA_COMMANDS="relog"
  45. EXTRA_HELP=" relog Reopen log files (without reloading)"