加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
start.sh 2.63 KB
一键复制 编辑 原始数据 按行查看 历史
CodingCattwo 提交于 2021-03-26 14:35 . optimize port
#!/bin/bash
APP_MAIN=com.webank.webase.node.mgr.Application
CLASSPATH='conf/:apps/*:lib/*'
CURRENT_DIR=$(pwd)/
LOG_DIR=${CURRENT_DIR}log
CONF_DIR=${CURRENT_DIR}conf
ARIAL_DIR=${CONF_DIR}/Arial
SERVER_PORT=$(cat $CONF_DIR/application.yml | grep "server:" -A 3 | grep "port" | awk '{print $2}'| sed 's/\r//')
if [ ${SERVER_PORT}"" = "" ];then
echo "$CONF_DIR/application.yml server port has not been configured"
exit -1
fi
if [ ${JAVA_HOME}"" = "" ];then
echo "JAVA_HOME has not been configured"
exit -1
fi
copyArial(){
arialFolder="/usr/share/fonts/arial"
if [ ! -d "$arialFolder" ]; then
sudo mkdir -p "$arialFolder" && sudo cp $ARIAL_DIR/arial*.ttf $arialFolder/
fi
}
mkdir -p log
startWaitTime=30
processPid=0
processStatus=0
checkProcess(){
server_pid=$(ps aux | grep java | grep $CURRENT_DIR | grep $APP_MAIN | awk '{print $2}')
if [ -n "$server_pid" ]; then
processPid=$server_pid
processStatus=1
else
processPid=0
processStatus=0
fi
}
JAVA_OPTS=" -Dfile.encoding=UTF-8"
JAVA_OPTS+=" -Djava.security.egd=file:/dev/./urandom"
JAVA_OPTS+=" -Xmx256m -Xms256m -Xmn128m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m"
JAVA_OPTS+=" -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}/heap_error.log"
start(){
copyArial
checkProcess
echo "==============================================================================================="
if [ $processStatus == 1 ]; then
echo "Server $APP_MAIN Port $SERVER_PORT is running PID($processPid)"
echo "==============================================================================================="
else
echo -n "Server $APP_MAIN Port $SERVER_PORT ..."
nohup $JAVA_HOME/bin/java -Djdk.tls.namedGroups="secp256k1" $JAVA_OPTS -cp $CLASSPATH $APP_MAIN >> $LOG_DIR/node-manager.out 2>&1 &
count=1
result=0
while [ $count -lt $startWaitTime ] ; do
checkProcess
if [ $processPid -ne 0 ]; then
result=1
break
fi
let count++
echo -n "."
sleep 1
done
if [ $result -ne 0 ]; then
echo "PID($processPid) [Starting]. Please message check through the log file (default path:./log/)."
echo "==============================================================================================="
else
echo "[Failed]. Please check message through the log file (default path:./log/)."
echo "==============================================================================================="
fi
fi
}
start
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化