자바 셸 스 크 립 트 시작

3341 단어 linux
i#!/bin/sh
#gameserver.sh
#To start or stop gameserver.

#base dir of the application
APP_BASE=`pwd`
echo $APP_BASE

#��ʼ��, ����, �����, ÿ���̵߳Ķ�ջ��С, ��ʼ�־ô�, �־ô����ֵ�ڴ��С
JDK_OPTS="-Xms3072m -Xmx3072m -Xmn1024m -Xss1m -XX:PermSize=128M -XX:MaxPermSize=128M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/game/server/app/castleserver/log/outmem.log"
#Eden����Survivor��Ĵ�С��ֵ
#JDK_OPTS=$JDK_OPTS" -XX:SurvivorRatio=1"
#���������Ϊ�����ռ�
JDK_OPTS=$JDK_OPTS" -XX:+UseParNewGC"
#ʹ��CMS�ڴ��ռ�
JDK_OPTS=$JDK_OPTS" -XX:+UseConcMarkSweepGC"
#���ٴκ�����ڴ�ѹ��
JDK_OPTS=$JDK_OPTS" -XX:CMSFullGCsBeforeCompaction=5"
#��FULL GC��ʱ��, �����ϴ�ѹ��
JDK_OPTS=$JDK_OPTS" -XX:+UseCMSCompactAtFullCollection"
#�����������ʱ��ռ�������е�ʱ��ٷֱ� 1/(1 + n)
JDK_OPTS=$JDK_OPTS" -XX:GCTimeRatio=19"
#�������������
JDK_OPTS=$JDK_OPTS" -Xnoclassgc"
#���ٰٷֱȺ�ʼʹ��cms�ռ���Ϊ�������, ����(Xmx - Xmn) * (100 - CMSInitiatingOccupancyFraction) / 100 >= Xmn
JDK_OPTS=$JDK_OPTS" -XX:CMSInitiatingOccupancyFraction=60"
#ÿ�׶ѿ��пռ���SoftReference�Ĵ��ʱ��
JDK_OPTS=$JDK_OPTS" -XX:SoftRefLRUPolicyMSPerMB=0"
#JMXԶ�̼���˿�����
JDK_OPTS=$JDK_OPTS" -Dcom.sun.management.jmxremote.port=8901 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=172.16.3.41"
JDK_OPTS=$JDK_OPTS" -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8801"
#jprofile����
#JDK_OPTS=$JDK_OPTS" -agentpath:/usr/local/jprofiler6/bin/linux-x64/libjprofilerti.so=port=7901"
#GC��־
JDK_OPTS=$JDK_OPTS" -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps"
JDK_OPTS=$JDK_OPTS" -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime"
JDK_OPTS=$JDK_OPTS" -XX:+PrintHeapAtGC -Xloggc:$APP_BASE/log/gc.log"
JDK_OPTS=$JDK_OPTS" -XX:ErrorFile=$APP_BASE/log/jvm_error%p.log"

#name of the application
APP_NAME=com.road.game.TestAnt
echo $APP_NAME

#name of the config file

#name of the file record the process id of the application
PROCESS_ID_FILE=$APP_BASE/gameserver.pid
echo $PROCESS_ID_FILE

#process id of the application
PROCESS_ID=`cat $PROCESS_ID_FILE`
echo $PROCESS_ID

case "$1" in
    start)
        if [ "$PROCESS_ID" ]; then
            echo "PID file ($PROCESS_ID) found. Is $APP_NAME still running? Start aborted."
            exit 1
        fi
        
        PATH=$CLASSPATH
        for i in $APP_BASE/*.jar;
        do
            PATH="$PATH":$i
        done
        
        for i in $APP_BASE/lib/*.jar;
        do
            PATH="$PATH":$i
        done
        echo $PATH
        
        $JAVA_HOME/bin/java -server $JDK_OPTS -cp "$PATH" "$APP_NAME"  &
        echo $! > $PROCESS_ID_FILE
        
        echo "$APP_NAME started!"
    ;;
    stop)
        if [ "$PROCESS_ID" ]; then
            kill "$PROCESS_ID"
            rm -rf $PROCESS_ID_FILE
            echo "----------------------the $APP_NAME been killed------------------"
        else
            echo "----------------------the $APP_NAME is not running----------------"
        fi
    ;;
    *)
        echo "Usage: $0 start|stop"
    ;;
esac
exit 0

좋은 웹페이지 즐겨찾기