You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StartSonar.bat 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. @rem SonarQube
  2. @rem Copyright (C) 2009-2022 SonarSource SA
  3. @rem mailto:info AT sonarsource DOT com
  4. @rem
  5. @rem This program is free software; you can redistribute it and/or
  6. @rem modify it under the terms of the GNU Lesser General Public
  7. @rem License as published by the Free Software Foundation; either
  8. @rem version 3 of the License, or (at your option) any later version.
  9. @rem
  10. @rem This program is distributed in the hope that it will be useful,
  11. @rem but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. @rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. @rem Lesser General Public License for more details.
  14. @rem
  15. @rem You should have received a copy of the GNU Lesser General Public License
  16. @rem along with this program; if not, write to the Free Software Foundation,
  17. @rem Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. @echo off
  19. setlocal
  20. rem DO NOT EDIT THE FOLLOWING SECTIONS
  21. set REALPATH=%~dp0
  22. set JAVA_EXE=
  23. call "%REALPATH%lib\find_java.bat" set_java_exe FAIL || goto:eof
  24. call :check_if_sonar_is_running FAIL || goto:eof
  25. echo Starting SonarQube...
  26. %JAVA_EXE% -Xms8m -Xmx32m^
  27. -Djava.awt.headless=true^
  28. --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED^
  29. --add-opens=java.base/java.lang=ALL-UNNAMED^
  30. --add-opens=java.base/java.nio=ALL-UNNAMED^
  31. --add-opens=java.base/sun.nio.ch=ALL-UNNAMED^
  32. --add-opens=java.management/sun.management=ALL-UNNAMED^
  33. --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED^
  34. -cp "%REALPATH%..\..\lib\sonar-application-@sqversion@.jar" "org.sonar.application.App"
  35. goto:eof
  36. :check_if_sonar_is_running
  37. set "SQ_SERVICE="
  38. for /f %%i in ('%REALPATH%SonarService.bat status ^>nul 2^>nul') do set "SQ_SERVICE=%%i"
  39. if [%SQ_SERVICE%]==[Started] (
  40. echo ERROR: SonarQube is already running as a service.
  41. exit /b 1
  42. )
  43. set "SQ_PROCESS="
  44. where jps >nul 2>nul
  45. if %errorlevel% equ 0 (
  46. rem give priority to jps command if present
  47. for /f "tokens=1" %%i in ('jps -l ^| findstr "org.sonar.application.App"') do set "SQ_PROCESS=%%i"
  48. ) else (
  49. rem fallback to wmic command
  50. for /f "tokens=2" %%i in ('wmic process where "name='java.exe' and commandline like '%%org.sonar.application.App%%'" get name^, processid 2^>nul ^| findstr "java"') do set "SQ_PROCESS=%%i"
  51. )
  52. if not [%SQ_PROCESS%]==[] (
  53. echo ERROR: Another instance of the SonarQube application is already running with PID %SQ_PROCESS%
  54. exit /b 1
  55. )
  56. exit /b 0
  57. endlocal