seata-server.bat 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. @REM Copyright 1999-2019 Seata.io Group.
  2. @REM
  3. @REM Licensed under the Apache License, Version 2.0 (the "License");
  4. @REM you may not use this file except in compliance with the License.
  5. @REM You may obtain a copy of the License at
  6. @REM
  7. @REM http://www.apache.org/licenses/LICENSE-2.0
  8. @REM
  9. @REM Unless required by applicable law or agreed to in writing, software
  10. @REM distributed under the License is distributed on an "AS IS" BASIS,
  11. @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. @REM See the License for the specific language governing permissions and
  13. @REM limitations under the License.
  14. @echo off
  15. chcp 65001
  16. set ERROR_CODE=0
  17. :init
  18. @REM Decide how to startup depending on the version of windows
  19. @REM -- Win98ME
  20. if NOT "%OS%"=="Windows_NT" goto Win9xArg
  21. @REM set local scope for the variables with windows NT shell
  22. if "%OS%"=="Windows_NT" @setlocal
  23. @REM -- 4NT shell
  24. if "%eval[2+2]" == "4" goto 4NTArgs
  25. @REM -- Regular WinNT shell
  26. set CMD_LINE_ARGS=%*
  27. goto WinNTGetScriptDir
  28. @REM The 4NT Shell from jp software
  29. :4NTArgs
  30. set CMD_LINE_ARGS=%$
  31. goto WinNTGetScriptDir
  32. :Win9xArg
  33. @REM Slurp the command line arguments. This loop allows for an unlimited number
  34. @REM of arguments (up to the command line limit, anyway).
  35. set CMD_LINE_ARGS=
  36. :Win9xApp
  37. if %1a==a goto Win9xGetScriptDir
  38. set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  39. shift
  40. goto Win9xApp
  41. :Win9xGetScriptDir
  42. set SAVEDIR=%CD%
  43. %0\
  44. cd %0\..\..
  45. set BASEDIR=%CD%
  46. cd %SAVEDIR%
  47. set SAVE_DIR=
  48. goto repoSetup
  49. :WinNTGetScriptDir
  50. set BASEDIR=%~dp0
  51. set BASEDIR=%BASEDIR:~0,-5%
  52. :repoSetup
  53. set REPO=
  54. if "%JAVACMD%"=="" set JAVACMD=java
  55. if "%REPO%"=="" set REPO=%BASEDIR%\lib
  56. set CLASSPATH="%BASEDIR%"\conf;"%REPO%"\*
  57. set ENDORSED_DIR=
  58. if NOT "%ENDORSED_DIR%" == "" set CLASSPATH="%BASEDIR%"\%ENDORSED_DIR%\*;%CLASSPATH%
  59. if NOT "%CLASSPATH_PREFIX%" == "" set CLASSPATH=%CLASSPATH_PREFIX%;%CLASSPATH%
  60. @REM Reaching here means variables are defined and arguments have been captured
  61. :endInit
  62. if exist %BASEDIR%/logs (
  63. echo "%BASEDIR%/logs"
  64. ) else (
  65. md "%BASEDIR%/logs"
  66. )
  67. if "%SKYWALKING_ENABLE%"=="true" (
  68. 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
  69. echo "apm-skywalking enabled opts: %SKYWALKING_OPTS%"
  70. ) else (
  71. echo "apm-skywalking not enabled"
  72. )
  73. %JAVACMD% %JAVA_OPTS% %SKYWALKING_OPTS% -server -Dloader.path="%BASEDIR%"/lib -Xmx2048m -Xms2048m -Xmn1024m -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 -Dlogging.config="%BASEDIR%"/conf/logback-spring.xml -jar "%BASEDIR%"/target/seata-server.jar %CMD_LINE_ARGS%
  74. if %ERRORLEVEL% NEQ 0 goto error
  75. goto end
  76. :error
  77. if "%OS%"=="Windows_NT" @endlocal
  78. set ERROR_CODE=%ERRORLEVEL%
  79. :end
  80. @REM set local scope for the variables with windows NT shell
  81. if "%OS%"=="Windows_NT" goto endNT
  82. @REM For old DOS remove the set variables from ENV - we assume they were not set
  83. @REM before we started - at least we don't leave any baggage around
  84. set CMD_LINE_ARGS=
  85. goto postExec
  86. :endNT
  87. @REM If error code is set to 1 then the endlocal was done already in :error.
  88. if %ERROR_CODE% EQU 0 @endlocal
  89. :postExec
  90. if "%FORCE_EXIT_ON_ERROR%" == "on" (
  91. if %ERROR_CODE% NEQ 0 exit %ERROR_CODE%
  92. )
  93. exit /B %ERROR_CODE%