57 lines
2.2 KiB
Bash
57 lines
2.2 KiB
Bash
|
#!/bin/sh
|
|||
|
|
|||
|
error_exit ()
|
|||
|
{
|
|||
|
echo "ERROR: $1 !!"
|
|||
|
exit 1
|
|||
|
}
|
|||
|
|
|||
|
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
|
|||
|
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
|
|||
|
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/opt/taobao/java
|
|||
|
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better!"
|
|||
|
|
|||
|
export MODE="cluster"
|
|||
|
while getopts ":m:" opt
|
|||
|
do
|
|||
|
case $opt in
|
|||
|
m)
|
|||
|
MODE=$OPTARG
|
|||
|
;;
|
|||
|
?)
|
|||
|
echo "未知参数"
|
|||
|
exit 1;;
|
|||
|
esac
|
|||
|
done
|
|||
|
|
|||
|
export JAVA_HOME
|
|||
|
export JAVA="$JAVA_HOME/bin/java"
|
|||
|
export BASE_DIR=`cd $(dirname $0)/..; pwd`
|
|||
|
export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
|
|||
|
|
|||
|
#===========================================================================================
|
|||
|
# JVM Configuration
|
|||
|
#===========================================================================================
|
|||
|
JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
|
|||
|
JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
|
|||
|
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
|
|||
|
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${BASE_DIR}/logs/nacos_gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
|
|||
|
JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
|
|||
|
if [[ "${MODE}" == "standalone" ]]; then
|
|||
|
JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true"
|
|||
|
fi
|
|||
|
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
|
|||
|
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
|
|||
|
JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/nacos-server.jar"
|
|||
|
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
|
|||
|
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
|
|||
|
if [ ! -d "${BASE_DIR}/logs" ]; then
|
|||
|
mkdir ${BASE_DIR}/logs
|
|||
|
fi
|
|||
|
if [ ! -f "${BASE_DIR}/logs/start.log" ]; then
|
|||
|
touch "${BASE_DIR}/logs/start.log"
|
|||
|
fi
|
|||
|
|
|||
|
|
|||
|
nohup $JAVA ${JAVA_OPT} > ${BASE_DIR}/logs/start.log 2>&1 &
|
|||
|
echo "nacos is starting,you can check the ${BASE_DIR}/logs/start.log"
|