seata-server.bat 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. @REM
  17. @echo off
  18. chcp 65001
  19. set ERROR_CODE=0
  20. :init
  21. @REM Decide how to startup depending on the version of windows
  22. @REM -- Win98ME
  23. if NOT "%OS%"=="Windows_NT" goto Win9xArg
  24. @REM set local scope for the variables with windows NT shell
  25. if "%OS%"=="Windows_NT" @setlocal
  26. @REM -- 4NT shell
  27. if "%eval[2+2]" == "4" goto 4NTArgs
  28. @REM -- Regular WinNT shell
  29. set CMD_LINE_ARGS=%*
  30. goto WinNTGetScriptDir
  31. @REM The 4NT Shell from jp software
  32. :4NTArgs
  33. set CMD_LINE_ARGS=%$
  34. goto WinNTGetScriptDir
  35. :Win9xArg
  36. @REM Slurp the command line arguments. This loop allows for an unlimited number
  37. @REM of arguments (up to the command line limit, anyway).
  38. set CMD_LINE_ARGS=
  39. :Win9xApp
  40. if %1a==a goto Win9xGetScriptDir
  41. set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  42. shift
  43. goto Win9xApp
  44. :Win9xGetScriptDir
  45. set SAVEDIR=%CD%
  46. %0\
  47. cd %0\..\..
  48. set BASEDIR=%CD%
  49. cd %SAVEDIR%
  50. set SAVE_DIR=
  51. goto repoSetup
  52. :WinNTGetScriptDir
  53. set BASEDIR=%~dp0
  54. set BASEDIR=%BASEDIR:~0,-5%
  55. :repoSetup
  56. set REPO=
  57. if "%JAVACMD%"=="" set JAVACMD=java
  58. if "%REPO%"=="" set REPO=%BASEDIR%\lib
  59. set CLASSPATH="%BASEDIR%"\conf;"%REPO%"\*
  60. set ENDORSED_DIR=
  61. if NOT "%ENDORSED_DIR%" == "" set CLASSPATH="%BASEDIR%"\%ENDORSED_DIR%\*;%CLASSPATH%
  62. if NOT "%CLASSPATH_PREFIX%" == "" set CLASSPATH=%CLASSPATH_PREFIX%;%CLASSPATH%
  63. @REM Reaching here means variables are defined and arguments have been captured
  64. :endInit
  65. if exist %BASEDIR%/logs (
  66. echo "%BASEDIR%/logs"
  67. ) else (
  68. md "%BASEDIR%/logs"
  69. )
  70. if "%SKYWALKING_ENABLE%"=="true" (
  71. set SKYWALKING_OPTS=-javaagent:"%BASEDIR%"/ext/apm-skywalking/skywalking-agent.jar -Dskywalking_config="%BASEDIR%"/ext/apm-skywalking/config/agent.config -Dskywalking.logging.dir="%BASEDIR%"/logs
  72. echo "apm-skywalking enabled opts: %SKYWALKING_OPTS%"
  73. ) else (
  74. echo "apm-skywalking not enabled"
  75. )
  76. if "%JMX_ENABLE%"=="true" (
  77. set JMX_PORT=%JMX_PORT%
  78. set JMX_OPTS=%JMX_OPTS%
  79. if "%JMX_OPTS%"=="" (
  80. set "JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
  81. )
  82. if "%JMX_PORT%"=="" (
  83. set "JMX_OPTS=%JMX_OPTS% -Dcom.sun.management.jmxremote.port=10055 -Dcom.sun.management.jmxremote.rmi.port=10055"
  84. )
  85. echo "JMX enabled"
  86. ) else (
  87. echo "JMX disabled"
  88. )
  89. %JAVACMD% %JAVA_OPTS% %SKYWALKING_OPTS% %JMX_OPTS% -server -Dloader.path="%BASEDIR%"/lib -Xmx2048m -Xms2048m -Xss512k -XX:SurvivorRatio=10 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=1024m -XX:-OmitStackTraceInFastThrow -XX:-UseAdaptiveSizePolicy -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%BASEDIR%"/logs/java_heapdump.hprof -XX:+DisableExplicitGC -Xloggc:"%BASEDIR%"/logs/seata_gc.log -verbose:gc -Dio.netty.leakDetectionLevel=advanced -classpath %CLASSPATH% -Dapp.name="seata-server" -Dapp.repo="%REPO%" -Dapp.home="%BASEDIR%" -Dbasedir="%BASEDIR%" -Dspring.config.location="%BASEDIR%"/conf/application.yml -Dspring.config.additional-location="%BASEDIR%"/conf/ -Dlogging.config="%BASEDIR%"/conf/logback-spring.xml -jar "%BASEDIR%"/target/seata-server.jar %CMD_LINE_ARGS%
  90. if %ERRORLEVEL% NEQ 0 goto error
  91. goto end
  92. :error
  93. if "%OS%"=="Windows_NT" @endlocal
  94. set ERROR_CODE=%ERRORLEVEL%
  95. :end
  96. @REM set local scope for the variables with windows NT shell
  97. if "%OS%"=="Windows_NT" goto endNT
  98. @REM For old DOS remove the set variables from ENV - we assume they were not set
  99. @REM before we started - at least we don't leave any baggage around
  100. set CMD_LINE_ARGS=
  101. goto postExec
  102. :endNT
  103. @REM If error code is set to 1 then the endlocal was done already in :error.
  104. if %ERROR_CODE% EQU 0 @endlocal
  105. :postExec
  106. if "%FORCE_EXIT_ON_ERROR%" == "on" (
  107. if %ERROR_CODE% NEQ 0 exit %ERROR_CODE%
  108. )
  109. exit /B %ERROR_CODE%