forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
46 lines (41 loc) · 1.1 KB
/
start.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
#!/bin/bash
APP=$1
APP=${APP:-"FullNode"}
START_OPT=`echo ${@:2}`
JAR_NAME="$APP.jar"
MAX_STOP_TIME=60
checkpid() {
pid=`ps -ef | grep $JAR_NAME |grep -v grep | awk '{print $2}'`
return $pid
}
stopService() {
count=1
while [ $count -le $MAX_STOP_TIME ]; do
checkpid
if [ $pid ]; then
kill -15 $pid
sleep 1
else
echo "java-tron stop"
return
fi
count=$[$count+1]
if [ $count -eq $MAX_STOP_TIME ]; then
kill -9 $pid
sleep 1
fi
done
}
startService() {
echo `date` >> start.log
total=`cat /proc/meminfo |grep MemTotal |awk -F ' ' '{print $2}'`
xmx=`echo "$total/1024/1024*0.8" | bc |awk -F. '{print $1"g"}'`
logtime=`date +%Y-%m-%d_%H-%M-%S`
nohup java -Xmx$xmx -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xloggc:./gc.log\
-XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:ReservedCodeCacheSize=256m\
-XX:+CMSScavengeBeforeRemark -jar $JAR_NAME $START_OPT -c config.conf >> start.log 2>&1 &
pid=`ps -ef |grep $JAR_NAME |grep -v grep |awk '{print $2}'`
echo "start java-tron with pid $pid on $HOSTNAME"
}
stopService
startService