#!/bin/sh
#
# Openresty-Nginx daemon control script.
# milisarge milisarge@gmail.com>.


openresty_start() {
  echo "Openresty başlatılıyor..."
  /opt/openresty/nginx/sbin/nginx -g 'pid /run/openresty.pid; daemon on; master_process on;'
}

openresty_prestart() {
  echo "Openresty ilk başlatılıyor..."
  /opt/openresty/nginx/sbin/nginx -t -q -g 'pid /run/openresty.pid; daemon on; master_process on;'
}

openresty_stop() {
  echo "Openrestly durduruluyor..."
  /opt/openresty/nginx/sbin/nginx -g 'pid /run/openresty.pid;' -s quit
}

openresty_reload() {
  echo "Openresty ayarları yeniden yukleniyor..."
  /opt/openresty/nginx/sbin/nginx -g 'pid /run/openresty.pid; daemon on; master_process on;' -s reload
}

openresty_restart() {
  openresty_stop
  sleep 3
  openresty_start
}

case "$1" in
  prestart)
    openresty_prestart
    ;;
  start)
    openresty_start
    ;;
  stop)
    openresty_stop
    ;;
  reload)
    openresty_reload
    ;;
  restart)
    openresty_restart
    ;;
  *)
  echo "usage: `basename $0` {prestart|start|stop|reload|restart}"
esac
