env.sh
4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#@Authro Lijian
#@Date 2007-05-24
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/functions.sh
export JAVA_HOME=/usr/local/java
export WEB_APP_HOME=/home/master/yoho-search-service/deploy
export SERVER_PORT=0
export PRODUCTION_MODE="TEST"
export SERVER_HOME=/usr/local/tomcat
export SERVER_TYPE=tomcat
export SERVER_NAMESPACE=search-service
export GW_URL=$Gateway_URL
export SERVER_BASE_DIR=" -Dcatalina.base=/home/master/yoho-search-service/deploy/.tomcat "
export NAMING_PORT=`expr 9000 + $SERVER_PORT`
export HTTP_SERVER_PORT=`expr 8080 + $SERVER_PORT`
export CHECK_SERVER_STARTUP_URL="http://127.0.0.1:$HTTP_SERVER_PORT/$SERVER_NAMESPACE/common/ok.jsp"
export STARTUP_SUCCESS_MSG="Server Online Resources ok"
export JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
export JAVA_DEBUG_OPT=" -server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=,server=y,suspend=n "
export TIGER_JMX_OPT=" -Dcom.sun.management.config.file=$WEB_APP_HOME/conf/jmx/jmx_monitor_management.properties "
if [ ! -e $JAVA_HOME ]; then
failed "********************************************************************"
failed "**Error: JAVA_HOME $JAVA_HOME not exist"
failed "********************************************************************"
exit 1
fi
if [ ! -e $SERVER_HOME ]; then
failed "********************************************************************"
failed "**Error: SERVER_HOME $SERVER_HOME not exist."
failed "********************************************************************"
exit 1
fi
#========end enviroment var define
if [ $PRODUCTION_MODE = "PRODUCT" ]; then
#after the environment of online is all 64-bit,the below if and else judgement can be delete
str=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$str" ]; then
let memTotal=`cat /proc/meminfo |grep MemTotal|awk '{printf "%d", $2/1024 }'`
if [ $memTotal -gt 10000 ];then
JAVA_MEM_OPTS=" -server -Xmx4000M -Xms4000M -Xmn1024M -XX:PermSize=200M -XX:MaxPermSize=400M -Xss256K -XX:+DisableExplicitGC -XX:SurvivorRatio=1 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -Xloggc:$WEB_APP_HOME/.tomcat/logs/gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$WEB_APP_HOME/.tomcat/logs/heapdump.hprof "
else
JAVA_MEM_OPTS=" -server -Xmx3000M -Xms3000M -Xmn1024M -XX:PermSize=200M -XX:MaxPermSize=400M -Xss256K -XX:+DisableExplicitGC -XX:SurvivorRatio=1 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -Xloggc:$WEB_APP_HOME/.tomcat/logs/gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$WEB_APP_HOME/.tomcat/logs/heapdump.hprof "
fi
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
JAVA_OPTS=" $JAVA_OPTS $JAVA_MEM_OPTS "
elif [ $PRODUCTION_MODE = "TEST" ]; then
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:MaxPermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
JAVA_OPTS=" $JAVA_OPTS $JAVA_MEM_OPTS "
elif [ $PRODUCTION_MODE = "DEV" ]; then
#we shuold reduce resource usage on developing mode
JAVA_MEM_OPTS=" -server -Xms64m -Xmx1024m -XX:MaxPermSize=128m "
JAVA_OPTS=" $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPT "
else
failed "********************************************************************"
failed "**Error: \$PRODUCTION_MODE should be only: run, test, dev"
failed "********************************************************************"
exit 1
fi
JAVA_OPTS=" $JAVA_OPTS $SERVER_BASE_DIR "
#jmx
export JMX_PORT=`expr 9900 + $SERVER_PORT`
export LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"|awk 'NR==1 {print}'`
export CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=$LOCAL_IP -Dcom.sun.management.jmxremote.port=$JMX_PORT -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"