feat(develop): [ISSUES #12013] startup.sh support environment CUSTOM_NACOS_MEMORY (#12014)

* use DISABLE_NACOS_DEFAULT_MEMORY_SETTING

* use CUSTOM_NACOS_MEMORY

* Code optimization

* remove unuse

* startup.cmd support CUSTOM_NACOS_MEMORY environment variable

---------

Co-authored-by: caoyanan <caoyanan@growingio.com>
This commit is contained in:
caoyanan666 2024-05-06 11:49:19 +08:00 committed by GitHub
parent 8d6f87eda6
commit 99807358df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,8 @@ rem if nacos startup mode is standalone
if %MODE% == "standalone" (
echo "nacos is starting with standalone"
set "NACOS_OPTS=-Dnacos.standalone=true"
set "NACOS_JVM_OPTS=-Xms512m -Xmx512m -Xmn256m"
if "%CUSTOM_NACOS_MEMORY%"=="" ( set "CUSTOM_NACOS_MEMORY=-Xms512m -Xmx512m -Xmn256m" )
set "NACOS_JVM_OPTS=%CUSTOM_NACOS_MEMORY%"
)
rem if nacos startup mode is cluster
@ -64,8 +65,8 @@ if %MODE% == "cluster" (
if %EMBEDDED_STORAGE% == "embedded" (
set "NACOS_OPTS=-DembeddedStorage=true"
)
set "NACOS_JVM_OPTS=-server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof -XX:-UseLargePages"
if "%CUSTOM_NACOS_MEMORY%"=="" ( set "CUSTOM_NACOS_MEMORY=-Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" )
set "NACOS_JVM_OPTS=-server %CUSTOM_NACOS_MEMORY% -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof -XX:-UseLargePages"
)
rem set nacos's functionMode

View File

@ -89,16 +89,15 @@ export CUSTOM_SEARCH_LOCATIONS=file:${BASE_DIR}/conf/
# JVM Configuration
#===========================================================================================
if [[ "${MODE}" == "standalone" ]]; then
JAVA_OPT="${JAVA_OPT} -Xms512m -Xmx512m -Xmn256m"
JAVA_OPT="${JAVA_OPT} ${CUSTOM_NACOS_MEMORY:- -Xms512m -Xmx512m -Xmn256m}"
JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true"
else
if [[ "${EMBEDDED_STORAGE}" == "embedded" ]]; then
JAVA_OPT="${JAVA_OPT} -DembeddedStorage=true"
fi
JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -server ${CUSTOM_NACOS_MEMORY:- -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m}"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASE_DIR}/logs/java_heapdump.hprof"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
fi
if [[ "${FUNCTION_MODE}" == "config" ]]; then