Add timeout and debug to geoloc members script
This commit is contained in:
parent
a9d85d974e
commit
8d095771fc
|
@ -4,26 +4,37 @@
|
||||||
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
|
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
|
||||||
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
|
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
|
||||||
source $GPATH/.env
|
source $GPATH/.env
|
||||||
timeout=5
|
timeout=120
|
||||||
|
startLoop=$(date +%s)
|
||||||
|
|
||||||
|
[[ $(ps -aux | grep "[g]eoloc-members") ]] && echo "ERROR: Script is still started... exit." && exit 1
|
||||||
|
|
||||||
|
echo "### $(date +%d-%m-%y) ###"
|
||||||
|
|
||||||
FILE="/tmp/geoloc-members.json"
|
FILE="/tmp/geoloc-members.json"
|
||||||
FINAL_LOCATION="$WEBPATH/data/geoloc-members.json"
|
FINAL_LOCATION="$WEBPATH/data/geoloc-members.json"
|
||||||
FINAL_LOCATION_ALT="$WEBPATH/data/geoloc-members-alt.json"
|
FINAL_LOCATION_ALT="$WEBPATH/data/geoloc-members-alt.json"
|
||||||
|
|
||||||
|
echo "Get wallets list"
|
||||||
|
|
||||||
DATA_MBR=$($JAKLIS listWallets --brut --mbr)
|
DATA_MBR=$($JAKLIS listWallets --brut --mbr)
|
||||||
DATA_NONMBR=$($JAKLIS listWallets --brut --non_mbr)
|
DATA_NONMBR=$($JAKLIS listWallets --brut --non_mbr)
|
||||||
DATA_LARF=$($JAKLIS listWallets --brut --larf)
|
DATA_LARF=$($JAKLIS listWallets --brut --larf)
|
||||||
|
|
||||||
echo "{\"wallets\":[" > $FILE
|
echo "{\"wallets\":[" > $FILE
|
||||||
|
|
||||||
|
echo "Start loop membres"
|
||||||
|
|
||||||
oldIFS=$IFS;
|
oldIFS=$IFS;
|
||||||
IFS=$'\n';
|
IFS=$'\n';
|
||||||
j=0
|
j=0
|
||||||
for i in $DATA_MBR; do
|
for i in $DATA_MBR; do
|
||||||
IFS=$oldIFS
|
IFS=$oldIFS
|
||||||
|
[[ $((`date +%s`-$startLoop)) -ge 72000 ]] && echo "ERROR: spent more than 20h ... exit." && exit 1
|
||||||
pubkey=$(echo $i | awk '{ print $1 }')
|
pubkey=$(echo $i | awk '{ print $1 }')
|
||||||
userId=\"$(echo $i | awk '{ print $2 }')\"
|
userId=\"$(echo $i | awk '{ print $2 }')\"
|
||||||
result=$(timeout $timeout $JAKLIS get -p $pubkey)
|
result=$(timeout $timeout $JAKLIS get -p $pubkey)
|
||||||
|
[[ $? -eq 124 ]] && echo "timeout $pubkey..." && continue
|
||||||
geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null)
|
geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null)
|
||||||
|
|
||||||
if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then
|
if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then
|
||||||
|
@ -39,12 +50,16 @@ for i in $DATA_MBR; do
|
||||||
((j++))
|
((j++))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Start non membres loop"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for i in $DATA_NONMBR; do
|
for i in $DATA_NONMBR; do
|
||||||
IFS=$oldIFS
|
IFS=$oldIFS
|
||||||
|
[[ $((`date +%s`-$startLoop)) -ge 72000 ]] && echo "ERROR: spent more than 20h ... exit." && exit 1
|
||||||
pubkey=$(echo $i | awk '{ print $1 }')
|
pubkey=$(echo $i | awk '{ print $1 }')
|
||||||
userId=\"$(echo $i | awk '{ print $2 }')\"
|
userId=\"$(echo $i | awk '{ print $2 }')\"
|
||||||
result=$(timeout $timeout $JAKLIS get -p $pubkey)
|
result=$(timeout $timeout $JAKLIS get -p $pubkey)
|
||||||
|
[[ $? -eq 124 ]] && echo "timeout $pubkey..." && continue
|
||||||
geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null)
|
geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null)
|
||||||
|
|
||||||
if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then
|
if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then
|
||||||
|
@ -60,9 +75,12 @@ for i in $DATA_NONMBR; do
|
||||||
((j++))
|
((j++))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Start larfeuil loop"
|
||||||
|
|
||||||
for i in $DATA_LARF; do
|
for i in $DATA_LARF; do
|
||||||
|
[[ $((`date +%s`-$startLoop)) -ge 72000 ]] && echo "ERROR: spent more than 20h ... exit." && exit 1
|
||||||
result=$(timeout $timeout $JAKLIS get -p $i)
|
result=$(timeout $timeout $JAKLIS get -p $i)
|
||||||
|
[[ $? -eq 124 ]] && echo "timeout $i" && continue
|
||||||
geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null)
|
geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null)
|
||||||
|
|
||||||
if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then
|
if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then
|
||||||
|
@ -84,6 +102,8 @@ echo "}]," >> $FILE
|
||||||
echo "\"time\": $nowD" >> $FILE
|
echo "\"time\": $nowD" >> $FILE
|
||||||
echo "}" >> $FILE
|
echo "}" >> $FILE
|
||||||
|
|
||||||
|
echo "Parse end result with jq"
|
||||||
|
|
||||||
finalResult=$(cat $FILE | jq .)
|
finalResult=$(cat $FILE | jq .)
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
|
||||||
|
@ -92,3 +112,5 @@ if [ $RESULT -eq 0 ]; then
|
||||||
else
|
else
|
||||||
echo "Failed" >> $FILE
|
echo "Failed" >> $FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "---"
|
||||||
|
|
Loading…
Reference in New Issue