forked from tronprotocol/tron-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestSync.sh
More file actions
executable file
·59 lines (49 loc) · 1.3 KB
/
Copy pathtestSync.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.3 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
#!/bin/bash
last_syncNum=0
response=$(curl -X GET http://127.0.0.1:8090/wallet/getnodeinfo)
# parse response
result=$(echo "$response" | jq -r '.beginSyncNum')
echo "result 1: $result, response 1: $response"
# shellcheck disable=SC2236
if [ ! -z "$result" ]; then
last_sync=$(printf "%d" "$result")
last_syncNum=$last_sync
echo "TRON node first sync: $last_sync"
else
alert="TRON node first sync error: : $response"
echo "$alert"
exit 1
fi
# interval as 10s
monitor_interval=10
# try 100 times
count=100
second_syncNum=0
check_sync_process() {
response=$(curl -X GET http://127.0.0.1:8090/wallet/getnodeinfo)
# parse response
result=$(echo "$response" | jq -r '.beginSyncNum')
echo "result 2: $result, response 2: $response"
# shellcheck disable=SC2236
if [ ! -z "$result" ]; then
last_sync=$(printf "%d" "$result")
second_syncNum=$last_sync
echo "TRON node second sync: $last_sync"
else
alert="TRON node second sync error: : $response"
echo "$alert"
exit 1
fi
}
# shellcheck disable=SC2004
for((i=1;i<=$count;i++)); do
echo "try i: $i"
sleep $monitor_interval
check_sync_process
if [ "$second_syncNum" -gt "$last_syncNum" ]; then
echo "sync increased"
exit 0
fi
done
echo "sync not increased"
exit 1