From f46ac1c311a22efbbad16bbd9534926e8a1e2b4a Mon Sep 17 00:00:00 2001 From: 3err0 Date: Fri, 14 Jun 2019 16:24:12 +0800 Subject: [PATCH] add timeout --- AntMinerGetAllpool | 3 ++- AntMinerGetAllstats | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/AntMinerGetAllpool b/AntMinerGetAllpool index 419db08..6215f39 100755 --- a/AntMinerGetAllpool +++ b/AntMinerGetAllpool @@ -9,8 +9,9 @@ set -o nounset ADDRESS=$1 PORT=$2 +TIMEOUT=0.5 -pools_raw=`echo '{"command":"pools"}' | nc $ADDRESS $PORT | tr -d '\0\n'` +pools_raw=`echo '{"command":"pools"}' | timeout $TIMEOUT nc $ADDRESS $PORT | tr -d '\0\n'` pools_raw=$(sed 's/}{/\},{/' <<< "$pools_raw") POOLS=$(jq '.POOLS' <<< "$pools_raw") diff --git a/AntMinerGetAllstats b/AntMinerGetAllstats index 75e9b69..b8193c5 100755 --- a/AntMinerGetAllstats +++ b/AntMinerGetAllstats @@ -9,8 +9,9 @@ set -o nounset ADDRESS=$1 PORT=$2 +TIMEOUT=0.5 -stats_raw=`echo '{"command":"stats"}' | nc $ADDRESS $PORT | tr -d '\0\n'` +stats_raw=`echo '{"command":"stats"}' | timeout $TIMEOUT nc $ADDRESS $PORT | tr -d '\0\n'` stats_raw=$(sed 's/}{/\},{/' <<< "$stats_raw") STATS=$(jq '.STATS' <<< "$stats_raw")