-
Notifications
You must be signed in to change notification settings - Fork 60
/
start.sh
84 lines (72 loc) · 2.63 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
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
#!/bin/bash
APP_MAIN=com.webank.webase.node.mgr.Application
CLASSPATH='conf/:apps/*:lib/*'
CURRENT_DIR=$(pwd)/
LOG_DIR=${CURRENT_DIR}log
CONF_DIR=${CURRENT_DIR}conf
ARIAL_DIR=${CONF_DIR}/Arial
SERVER_PORT=$(cat $CONF_DIR/application.yml | grep "server:" -A 3 | grep "port" | awk '{print $2}'| sed 's/\r//')
if [ ${SERVER_PORT}"" = "" ];then
echo "$CONF_DIR/application.yml server port has not been configured"
exit -1
fi
if [ ${JAVA_HOME}"" = "" ];then
echo "JAVA_HOME has not been configured"
exit -1
fi
copyArial(){
arialFolder="/usr/share/fonts/arial"
if [ ! -d "$arialFolder" ]; then
sudo mkdir -p "$arialFolder" && sudo cp $ARIAL_DIR/arial*.ttf $arialFolder/
fi
}
mkdir -p log
startWaitTime=30
processPid=0
processStatus=0
checkProcess(){
server_pid=$(ps aux | grep java | grep $CURRENT_DIR | grep $APP_MAIN | awk '{print $2}')
if [ -n "$server_pid" ]; then
processPid=$server_pid
processStatus=1
else
processPid=0
processStatus=0
fi
}
JAVA_OPTS=" -Dfile.encoding=UTF-8"
JAVA_OPTS+=" -Djava.security.egd=file:/dev/./urandom"
JAVA_OPTS+=" -Xmx256m -Xms256m -Xmn128m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m"
JAVA_OPTS+=" -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}/heap_error.log"
start(){
copyArial
checkProcess
echo "==============================================================================================="
if [ $processStatus == 1 ]; then
echo "Server $APP_MAIN Port $SERVER_PORT is running PID($processPid)"
echo "==============================================================================================="
else
echo -n "Server $APP_MAIN Port $SERVER_PORT ..."
nohup $JAVA_HOME/bin/java -Djdk.tls.namedGroups="secp256k1" $JAVA_OPTS -cp $CLASSPATH $APP_MAIN >> $LOG_DIR/node-manager.out 2>&1 &
count=1
result=0
while [ $count -lt $startWaitTime ] ; do
checkProcess
if [ $processPid -ne 0 ]; then
result=1
break
fi
let count++
echo -n "."
sleep 1
done
if [ $result -ne 0 ]; then
echo "PID($processPid) [Starting]. Please message check through the log file (default path:./log/)."
echo "==============================================================================================="
else
echo "[Failed]. Please check message through the log file (default path:./log/)."
echo "==============================================================================================="
fi
fi
}
start