solr-exporter.cmd 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. @REM
  2. @REM Licensed to the Apache Software Foundation (ASF) under one or more
  3. @REM contributor license agreements. See the NOTICE file distributed with
  4. @REM this work for additional information regarding copyright ownership.
  5. @REM The ASF licenses this file to You under the Apache License, Version 2.0
  6. @REM (the "License"); you may not use this file except in compliance with
  7. @REM the License. You may obtain a copy of the License at
  8. @REM
  9. @REM http://www.apache.org/licenses/LICENSE-2.0
  10. @REM
  11. @REM Unless required by applicable law or agreed to in writing, software
  12. @REM distributed under the License is distributed on an "AS IS" BASIS,
  13. @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. @REM See the License for the specific language governing permissions and
  15. @REM limitations under the License.
  16. @echo off
  17. set ERROR_CODE=0
  18. :init
  19. @REM Decide how to startup depending on the version of windows
  20. @REM -- Win98ME
  21. if NOT "%OS%"=="Windows_NT" goto Win9xArg
  22. @REM set local scope for the variables with windows NT shell
  23. if "%OS%"=="Windows_NT" @setlocal
  24. @REM -- 4NT shell
  25. if "%eval[2+2]" == "4" goto 4NTArgs
  26. @REM -- Regular WinNT shell
  27. set CMD_LINE_ARGS=%*
  28. goto WinNTGetScriptDir
  29. @REM The 4NT Shell from jp software
  30. :4NTArgs
  31. set CMD_LINE_ARGS=%$
  32. goto WinNTGetScriptDir
  33. :Win9xArg
  34. @REM Slurp the command line arguments. This loop allows for an unlimited number
  35. @REM of agruments (up to the command line limit, anyway).
  36. set CMD_LINE_ARGS=
  37. :Win9xApp
  38. if %1a==a goto Win9xGetScriptDir
  39. set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  40. shift
  41. goto Win9xApp
  42. :Win9xGetScriptDir
  43. set SAVEDIR=%CD%
  44. %0\
  45. cd %0\..\..
  46. set BASEDIR=%CD%
  47. cd %SAVEDIR%
  48. set SAVE_DIR=
  49. goto repoSetup
  50. :WinNTGetScriptDir
  51. set BASEDIR=%~dp0..
  52. :repoSetup
  53. if "%JAVACMD%"=="" set JAVACMD=java
  54. if "%REPO%"=="" set REPO=%BASEDIR%\lib
  55. set CLASSPATH=%REPO%\*;%BASEDIR%\..\..\dist\solrj-lib\*;%BASEDIR%\..\..\dist\*;%BASEDIR%\lucene-libs\*;%BASEDIR%\..\..\server\solr-webapp\webapp\WEB-INF\lib\*
  56. set EXTRA_JVM_ARGUMENTS=-Xmx512m -Dlog4j.configurationFile=file:///%BASEDIR%\..\..\server\resources\log4j2-console.xml
  57. goto endInit
  58. @REM Reaching here means variables are defined and arguments have been captured
  59. :endInit
  60. %JAVACMD% %JAVA_OPTS% %EXTRA_JVM_ARGUMENTS% -classpath "%CLASSPATH_PREFIX%;%CLASSPATH%" -Dapp.name="solr-exporter" -Dapp.repo="%REPO%" -Dbasedir="%BASEDIR%" org.apache.solr.prometheus.exporter.SolrExporter %CMD_LINE_ARGS%
  61. if ERRORLEVEL 1 goto error
  62. goto end
  63. :error
  64. if "%OS%"=="Windows_NT" @endlocal
  65. set ERROR_CODE=1
  66. :end
  67. @REM set local scope for the variables with windows NT shell
  68. if "%OS%"=="Windows_NT" goto endNT
  69. @REM For old DOS remove the set variables from ENV - we assume they were not set
  70. @REM before we started - at least we don't leave any baggage around
  71. set CMD_LINE_ARGS=
  72. goto postExec
  73. :endNT
  74. @endlocal
  75. :postExec
  76. if "%FORCE_EXIT_ON_ERROR%" == "on" (
  77. if %ERROR_CODE% NEQ 0 exit %ERROR_CODE%
  78. )
  79. exit /B %ERROR_CODE%