From d1096a270fd2b5ad685c6c344beb77bd7fbabd74 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sat, 3 Feb 2018 23:46:52 +0100 Subject: [PATCH] Bugs solved in Nginx starting scripts --- services/nginx/start.cmd | 12 ++++++------ services/nginx/start.sh | 15 +++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/services/nginx/start.cmd b/services/nginx/start.cmd index b7478eb71..45c1440a9 100644 --- a/services/nginx/start.cmd +++ b/services/nginx/start.cmd @@ -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 diff --git a/services/nginx/start.sh b/services/nginx/start.sh index 90037daa5..a2287ecb8 100755 --- a/services/nginx/start.sh +++ b/services/nginx/start.sh @@ -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]"