cache "$result" > /tmp/zen/current.duniter for 15mn

This commit is contained in:
qo-op 2020-05-11 07:33:01 +02:00
parent 7f905a45c9
commit 632ca11e8c
2 changed files with 16 additions and 2 deletions

View File

@ -56,6 +56,10 @@ DIR=/tmp/zen/gnodewatch
export DIR
mkdir -p $DIR/chains
# KEEP /tmp/zen/current.duniter for 15 mn
find /tmp/zen/ -cmin +15 -type f -name "current.duniter" -exec rm -f '{}' \;
[[ -f /tmp/zen/current.duniter ]] && cat /tmp/zen/current.duniter && exit 0
##### $DIR/duniter_nodes.txt REFRESH after 20 minutes #####
find $DIR/ -cmin +20 -type f -name "duniter_*" -exec rm -f '{}' \;
if [[ ! -f $DIR/duniter_nodes.txt ]]; then
@ -105,4 +109,7 @@ longchain=$(ls -S $DIR/chains/ | head -n 1)
cp $DIR/chains/$longchain $DIR/good.nodes.txt
# WRITE OUT shuffle Duniter Node Sync with longest chain
result=$(shuf -n 1 $DIR/good.nodes.txt)
[[ ! $result ]] && echo "duniter-g1.p2p.legal:443" || echo $result
[[ ! $result ]] && result="duniter-g1.p2p.legal:443"
echo "$result" > /tmp/zen/current.duniter
echo $result

View File

@ -56,6 +56,10 @@ DIR=/tmp/zen/gnodewatch
export DIR
mkdir -p $DIR/chains
# KEEP /tmp/zen/current.duniter for 15 mn
find /tmp/zen/ -cmin +15 -type f -name "current.duniter" -exec rm -f '{}' \;
[[ -f /tmp/zen/current.duniter ]] && cat /tmp/zen/current.duniter && exit 0
##### $DIR/duniter_nodes.txt REFRESH after 20 minutes #####
find $DIR/ -cmin +20 -type f -name "duniter_*" -exec rm -f '{}' \;
if [[ ! -f $DIR/duniter_nodes.txt ]]; then
@ -105,4 +109,7 @@ longchain=$(ls -S $DIR/chains/ | head -n 1)
cp $DIR/chains/$longchain $DIR/good.nodes.txt
# WRITE OUT shuffle Duniter Node Sync with longest chain
result=$(shuf -n 1 $DIR/good.nodes.txt)
[[ ! $result ]] && echo "duniter-g1.p2p.legal:443" || echo $result
[[ ! $result ]] && result="duniter-g1.p2p.legal:443"
echo "$result" > /tmp/zen/current.duniter
echo $result