spring-cloud 项目外部启动引导文件参考shell脚本

!/bin/bash

cd dirname $0
BIN_DIR=pwd
STDOUT_FILE=DEPLOY_DIR/conf
DEPLOY_LIBS_DIR=$DEPLOY_DIR/lib/*

SERVER_NAME=sed '/spring.application.name/!d;s/.*=//' conf/application.properties | tr -d '\r'
SERVER_PORT=sed '/server.port/!d;s/.*=//' conf/application.properties | tr -d '\r'
SERVER_PIDS=ps -ef | grep java | grep "$DEPLOY_CONF_DIR" | awk '{print $2}'

if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=hostname
fi

if [ -n "SERVER_NAME already started!"
echo "PID: $SERVER_PIDS"
exit 1
fi

if [ -n "SERVER_PORT" | wc -l`
if [ "SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi

LOGS_DIR=log
if [ ! -d "LOGS_DIR"
fi

STDOUT_FILE=$LOGS_DIR/stdout.log

ready opts...

JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "1" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=java -version 2>&1 | grep -i 64-bit
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -XX:PermSize=128m -Xmn256m -Xss256k
-XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection
-XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi

start service...

BOOT_CLASS="com.dq.cloud.eureka.EurekaApplication"
echo -e "Starting the JAVA_OPTS JAVA_DEBUG_OPTS DEPLOY_CONF_DIR:BOOT_CLASS > DEPLOY_DIR" | awk '{print SERVER_PIDS"
echo "STDOUT: $STDOUT_FILE"

你可能感兴趣的:(spring-cloud 项目外部启动引导文件参考shell脚本)