java 启动shell脚本

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值