-
Notifications
You must be signed in to change notification settings - Fork 37
/
run.sh
96 lines (91 loc) · 3.28 KB
/
run.sh
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
export JAVA_HOME=/usr/local/jdk/jdk1.7.0_71
#check JAVA_HOME & java
noJavaHome=false
if [ -z "$JAVA_HOME" ] ; then
noJavaHome=true
fi
if [ ! -e "$JAVA_HOME/bin/java" ] ; then
noJavaHome=true
fi
if $noJavaHome ; then
echo
echo "Error: JAVA_HOME environment variable is not set."
echo
exit 1
fi
#==============================================================================
#set HOME
CURR_DIR=`pwd`
cd `dirname "$0"`/..
FEEYO_HOME=`pwd`
cd $CURR_DIR
if [ -z "$FEEYO_HOME" ] ; then
echo
echo "Error: FEEYO_HOME environment variable is not defined correctly."
echo
exit 1
fi
#==============================================================================
#set CLASSPATH
FEEYO_CLASSPATH="$FEEYO_HOME/conf:$FEEYO_HOME/lib/classes"
for i in "$FEEYO_HOME"/lib/*.jar
do
FEEYO_CLASSPATH="$FEEYO_CLASSPATH:$i"
done
#==============================================================================
#set JAVA_OPTS & PID_FILE & RUN_CMD
SERVICE_NAME="feeyoredisproxy"
logFile="$FEEYO_HOME/logs/console.log"
pidFile="$FEEYO_HOME/bin/run.pid"
#===========================================================================================
# JVM Configuration
#===========================================================================================
JAVA_OPTS="${JAVA_OPTS} -server -Xms2g -Xmx2g -Xmn1g -XX:PermSize=128m -XX:MaxPermSize=128m -XX:SurvivorRatio=18 -XX:MaxDirectMemorySize=1g"
JAVA_OPTS="${JAVA_OPTS} -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
JAVA_OPTS="${JAVA_OPTS} -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=5"
JAVA_OPTS="${JAVA_OPTS} -XX:+CMSParallelRemarkEnabled -XX:CMSMaxAbortablePrecleanTime=5000"
JAVA_OPTS="${JAVA_OPTS} -XX:+DisableExplicitGC -XX:+UseParNewGC"
JAVA_OPTS="${JAVA_OPTS} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$FEEYO_HOME/logs/feeyoredisproxy_java.hprof"
JAVA_OPTS="${JAVA_OPTS} -verbose:gc -Xloggc:$FEEYO_HOME/logs/feeyoredisproxy_gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC"
JAVA_OPTS="${JAVA_OPTS} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=100M"
#JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_RUN="$JAVA_HOME/bin/java"
JAVA_RUN="$JAVA_RUN -DFEEYO_HOME=\"$FEEYO_HOME\""
JAVA_RUN="$JAVA_RUN -classpath \"$FEEYO_CLASSPATH\""
JAVA_RUN="$JAVA_RUN $JAVA_OPTS"
JAVA_RUN="$JAVA_RUN com.feeyo.redis.RedisServer $@"
JAVA_RUN="$JAVA_RUN >> \"$logFile\" 2>&1 & echo \$! >$pidFile"
feeyo_pid=`ps -ef | grep 'feeyoredisproxy' | grep java | awk '{print $2}'`
start(){
if [ -z $feeyo_pid ];then
echo $JAVA_RUN
eval $JAVA_RUN
echo "$SERVICE_NAME started ..."
else
echo "feeyoredisproxy is exit,please check..."
fi
}
stop(){
kill $feeyo_pid >/dev/null 2>&1
sleep 2
feeyo_pid=`ps -ef | grep 'feeyoredisproxy' | grep java | awk '{print $2}'`
if [ -z $feeyo_pid ];then
echo "stop success!!!"
else
kill -9 $feeyo_pid >/dev/null 2>&1
echo "stop success!!!"
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
esac