Bugs solved in Nginx starting scripts

This commit is contained in:
Juan Ferrer Toribio 2018-02-03 23:46:52 +01:00
parent 4a388f241c
commit d1096a270f
2 changed files with 15 additions and 12 deletions

View File

@ -1,8 +1,8 @@
@echo off
set currentDir=%cd%
set nginxPrefix=%currentDir%\services\nginx
set nginxConf=%nginxPrefix%\temp\nginx.conf
set nginxDir=%~dp0
set nginxTemp=%nginxDir%\temp
set nginxConf=%nginxTemp%\nginx.conf
if "%1"=="" goto caseStart
if "%1"=="start" goto caseStart
@ -12,13 +12,13 @@ goto caseUsage
:caseStart
call "%0" stop
echo Starting nginx.
if not exist "%nginxPrefix%\temp" (mkdir "%nginxPrefix%\temp")
start /I nginx -c "%nginxConf%" -p "%nginxPrefix%"
if not exist "%nginxTemp%" (mkdir "%nginxTemp%")
start /I nginx -c "%nginxConf%" -p "%nginxDir%"
goto caseEnd
:caseStop
echo Stoping nginx.
if exist "%nginxPrefix%\temp\nginx.pid" (nginx -c "%nginxConf%" -p "%nginxPrefix%" -s stop)
if exist "%nginxTemp%\nginx.pid" (nginx -c "%nginxConf%" -p "%nginxDir%" -s stop)
goto caseEnd
:caseUsage

View File

@ -1,23 +1,26 @@
#!/bin/bash
nginxDir="$(dirname $0)"
nginxTemp="$nginxDir/temp"
nginxConf="temp/nginx.conf"
nginxBin="/usr/sbin/nginx"
nginxPrefix="${PWD}/services/nginx"
nginxConf="$nginxPrefix/temp/nginx.conf"
if [ ! -f $nginxBin ]; then
nginxBin="nginx"
fi
echo $nginxConf $nginxDir
case "$1" in
start|"")
$0 stop
echo "Starting nginx."
mkdir -p "$nginxPrefix/temp"
"$nginxBin" -c "$nginxConf" -p "$nginxPrefix" 2>> /dev/null
mkdir -p "$nginxTemp"
"$nginxBin" -c "$nginxConf" -p "$nginxDir"
;;
stop)
echo "Stoping nginx."
"$nginxBin" -c "$nginxConf" -p "$nginxPrefix" -s stop 2>> /dev/null
if [ -f "$nginxTemp/nginx.pid" ]; then
"$nginxBin" -c "$nginxConf" -p "$nginxDir" -s stop
fi
;;
*)
echo "Usage: `basename "$0"` [start|stop]"