Last active
August 29, 2017 03:44
-
-
Save alswl/1238a0227ef1bdd6e0f74cace6484c65 to your computer and use it in GitHub Desktop.
common JVM start bin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bin scripts for java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME="APP-NAME" | |
DEFAULT_JAVA_HOME="/opt/java8" | |
DEFAULT_MVN_BIN="mvn" | |
DEFAULT_JAR_FILE="APP-NAME-shaded.jar" | |
DEFAULT_CONF_FILE="/etc/conf/app/APP-NAME/conf.yaml" | |
DEFAULT_PID_PATH="/var/work/APP-NAME.pid" | |
STD_LOG_PATH="/var/logs/usr/APP-NAME/std.log" | |
if [ -z $JAVA_HOME ]; then | |
export JAVA_HOME=$DEFAULT_JAVA_HOME | |
fi | |
if [ -z $MVN_BIN ]; then | |
export MVN_BIN=$DEFAULT_MVN_BIN | |
fi | |
if [ -z $JAR_FILE ]; then | |
export JAR_FILE=$DEFAULT_JAR_FILE | |
fi | |
if [ -z $CONF_FILE ]; then | |
export CONF_FILE=$DEFAULT_CONF_FILE | |
fi | |
if [ -z $PID_PATH ]; then | |
export PID_PATH=$DEFAULT_PID_PATH | |
fi | |
export STD_LOG_PATH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -x | |
set -e | |
cd `dirname $0`/../ | |
./bin/stop.sh | |
sleep 2 | |
./bin/start.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -x | |
set -e | |
cd `dirname $0`/../ | |
source ./bin/env.sh | |
if [ -f $PID_PATH ]; then | |
echo "$NAME is already running $(cat $PID_PATH) ..." | |
exit -1 | |
fi | |
JAVA_OPTS="-Xmx1g -Xms1g -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:+DisableExplicitGC -XX:+AlwaysPreTouch" | |
JAVA_OPTS="$JAVA_OPTS -XX:NewRatio=1 -XX:SurvivorRatio=3" | |
JAVA_OPTS="$JAVA_OPTS -XX:+UnlockCommercialFeatures -XX:+FlightRecorder" | |
JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/logs/usr/APP-NAME/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=30 -XX:GCLogFileSize=10m" | |
nohup $JAVA_HOME/bin/java $JAVA_OPTS -jar $JAR_FILE server $CONF_FILE 2>&1 > $STD_LOG_PATH & | |
echo $! > $PID_PATH | |
echo "$NAME is running ..." | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -x | |
set -e | |
cd `dirname $0`/../ | |
source ./bin/env.sh | |
if [ -f $PID_PATH ]; then | |
PID=$(cat $PID_PATH); | |
echo "$NAME stoping ..." | |
kill $PID; | |
echo "$NAME stopped ..." | |
rm $PID_PATH | |
else | |
echo "$NAME is not running ..." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment