forked from DorianRust/one-click-deployment
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.startNode.sh
49 lines (45 loc) · 1.05 KB
/
.startNode.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
#!/bin/bash
APP="java-tron-1.0.0"
JAR_NAME="$APP.zip"
FullNode="FullNode"
MAX_STOP_TIME=60
Program="program.FullNode"
SRKEY=$1
checkpid() {
pid=`ps ux | grep $Program |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`
if [ -z $SRKEY ];then
nohup $APP/bin/$FullNode -c config.conf >> start.log 2>&1 &
else
nohup $APP/bin/$FullNode -w --private-key $SRKEY -c config.conf >> start.log 2>&1 &
fi
sleep 1
pid=`ps ux |grep $Program |grep -v grep |awk '{print $2}'`
echo "start java-tron with pid $pid on $HOSTNAME"
}
stopService
startService