From 91bb6faaafe45bb8ee90ec91d39cb556e7da1f5b Mon Sep 17 00:00:00 2001 From: Dimitris Kavvathas Date: Mon, 8 Aug 2022 15:30:22 +0200 Subject: [PATCH] Add realpath and check for running service --- .../main/assembly/bin/windows-x86-64/StartSonar.bat | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sonar-application/src/main/assembly/bin/windows-x86-64/StartSonar.bat b/sonar-application/src/main/assembly/bin/windows-x86-64/StartSonar.bat index 3214ab5ea1a..500b5cbe8f3 100755 --- a/sonar-application/src/main/assembly/bin/windows-x86-64/StartSonar.bat +++ b/sonar-application/src/main/assembly/bin/windows-x86-64/StartSonar.bat @@ -24,8 +24,10 @@ set JAVA_EXE="java" rem DO NOT EDIT THE FOLLOWING SECTIONS +set REALPATH=%~dp0 call :check_if_sonar_is_running FAIL || goto:eof +echo Starting SonarQube... %JAVA_EXE% -Xms8m -Xmx32m^ -Djava.awt.headless=true^ --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED^ @@ -34,11 +36,18 @@ call :check_if_sonar_is_running FAIL || goto:eof --add-opens=java.base/sun.nio.ch=ALL-UNNAMED^ --add-opens=java.management/sun.management=ALL-UNNAMED^ --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED^ - -cp "..\..\lib\sonar-application-@sqversion@.jar" "org.sonar.application.App" + -cp "%REALPATH%..\..\lib\sonar-application-@sqversion@.jar" "org.sonar.application.App" goto:eof :check_if_sonar_is_running +set "SQ_SERVICE=" +for /f %%i in ('%REALPATH%/SonarService.exe status') do set "SQ_SERVICE=%%i" +if [%SQ_SERVICE%]==[Started] ( + echo ERROR: SonarQube is already running as a service. + exit /b 1 +) + set "SQ_PROCESS=" where jps >nul 2>nul if %errorlevel% equ 0 ( -- 2.39.5