FFmpeg-Builds/images/base/retry-tool.sh

17 lines
402 B
Bash
Raw Normal View History

2022-07-12 23:46:13 +00:00
#!/bin/bash
set -xe
RETRY_COUNTER=0
MAX_RETRY=10
CUR_TIMEOUT=120
2022-07-12 23:46:13 +00:00
while [[ $RETRY_COUNTER -lt $MAX_RETRY ]]; do
timeout $CUR_TIMEOUT "$@" && break || sleep $(shuf -i 5-90 -n 1)
2022-07-12 23:46:13 +00:00
RETRY_COUNTER=$(( $RETRY_COUNTER + 1 ))
CUR_TIMEOUT=$(( $CUR_TIMEOUT + 60 ))
2022-07-12 23:46:13 +00:00
echo "Retry $RETRY_COUNTER..."
done
if [[ $RETRY_COUNTER -ge $MAX_RETRY ]]; then
echo "Max retry count exceeded."
exit 1
fi