#!/bin/sh /etc/rc.common START=95 STOP=10 USE_PROCD=1 NGINX_BIN="" NGINX_CONF="/etc/nginx/nginx.conf" resolve_nginx() { for candidate in "$(command -v nginx 2>/dev/null)" /usr/local/usr/sbin/nginx /usr/sbin/nginx /usr/bin/nginx; do if [ -n "$candidate" ] && [ -x "$candidate" ]; then NGINX_BIN="$candidate" return 0 fi done logger -t racecore-nginx "nginx executable not found" return 1 } prepare_runtime() { mkdir -p /tmp/nginx/client_body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi } start_service() { resolve_nginx || return 1 prepare_runtime "$NGINX_BIN" -t -c "$NGINX_CONF" || return 1 procd_open_instance procd_set_param command "$NGINX_BIN" -c "$NGINX_CONF" -g "daemon off;" procd_set_param respawn 3600 5 5 procd_set_param file "$NGINX_CONF" procd_set_param stdout 1 procd_set_param stderr 1 procd_close_instance } reload_service() { resolve_nginx || return 1 prepare_runtime "$NGINX_BIN" -t -c "$NGINX_CONF" || return 1 "$NGINX_BIN" -s reload -c "$NGINX_CONF" }