startup.cmd 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. @echo off
  2. rem Copyright 1999-2018 Alibaba Group Holding Ltd.
  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. if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1
  15. set "JAVA=%JAVA_HOME%\bin\java.exe"
  16. setlocal enabledelayedexpansion
  17. set BASE_DIR=%~dp0
  18. rem added double quotation marks to avoid the issue caused by the folder names containing spaces.
  19. rem removed the last 5 chars(which means \bin\) to get the base DIR.
  20. set BASE_DIR="%BASE_DIR:~0,-5%"
  21. set DEFAULT_SEARCH_LOCATIONS="classpath:/,classpath:/config/,file:./,file:./config/"
  22. set CUSTOM_SEARCH_LOCATIONS=%DEFAULT_SEARCH_LOCATIONS%,file:%BASE_DIR%/conf/
  23. set MODE="standalone"
  24. set FUNCTION_MODE="all"
  25. set MODE_INDEX=-1
  26. set FUNCTION_MODE_INDEX=-1
  27. set i=0
  28. for %%a in (%*) do (
  29. if "%%a" == "-m" ( set /a MODE_INDEX=!i!+1 )
  30. if "%%a" == "-f" ( set /a FUNCTION_MODE_INDEX=!i!+1 )
  31. set /a i+=1
  32. )
  33. set i=0
  34. for %%a in (%*) do (
  35. if %MODE_INDEX% == !i! ( set MODE="%%a" )
  36. if %FUNCTION_MODE_INDEX% == !i! ( set FUNCTION_MODE="%%a" )
  37. set /a i+=1
  38. )
  39. if %MODE% == "standalone" (
  40. set "JAVA_OPT=%JAVA_OPT% -Xms512m -Xmx512m -Xmn256m"
  41. set "JAVA_OPT=%JAVA_OPT% -Dnacos.standalone=true"
  42. ) else (
  43. set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
  44. set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof"
  45. set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
  46. )
  47. if %FUNCTION_MODE% == "config" (
  48. set "JAVA_OPT=%JAVA_OPT% -Dnacos.functionMode=config"
  49. )
  50. if %FUNCTION_MODE% == "naming" (
  51. set "JAVA_OPT=%JAVA_OPT% -Dnacos.functionMode=naming"
  52. )
  53. set "JAVA_OPT=%JAVA_OPT% -Xbootclasspath/a:%BASE_DIR%\plugins\cmdb:%BASE_DIR%\plugins\mysql"
  54. set "JAVA_OPT=%JAVA_OPT% -Dnacos.home=%BASE_DIR%"
  55. set "JAVA_OPT=%JAVA_OPT% -Dloader.path=%BASE_DIR%/plugins/health -jar %BASE_DIR%\target\nacos-server.jar"
  56. set "JAVA_OPT=%JAVA_OPT% --spring.config.location=%CUSTOM_SEARCH_LOCATIONS%"
  57. set "JAVA_OPT=%JAVA_OPT% --logging.config=%BASE_DIR%/conf/nacos-logback.xml"
  58. call "%JAVA%" %JAVA_OPT% nacos.nacos %*