mirror of
https://github.com/thegeeklab/retry.git
synced 2024-11-28 07:30:36 +00:00
fix so many problems with first bash implementation #6
This commit is contained in:
parent
00c4bbcbfb
commit
3b9de02bd8
10
retry
10
retry
@ -4,6 +4,8 @@ __sleep_amount() {
|
|||||||
if [ -n "$constant_sleep" ]; then
|
if [ -n "$constant_sleep" ]; then
|
||||||
sleep_time=$constant_sleep
|
sleep_time=$constant_sleep
|
||||||
else
|
else
|
||||||
|
#TODO: check for awk
|
||||||
|
#TODO: check if user would rather use one of the other possible dependencies: python, ruby, bc, dc
|
||||||
sleep_time=`awk "BEGIN {t = $min_sleep * $(( (1<<($attempts -1)) )); print (t > $max_sleep ? $max_sleep : t)}"`
|
sleep_time=`awk "BEGIN {t = $min_sleep * $(( (1<<($attempts -1)) )); print (t > $max_sleep ? $max_sleep : t)}"`
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -38,7 +40,11 @@ retry()
|
|||||||
__log_out "Before retry #$attempts: sleeping $sleep_time seconds"
|
__log_out "Before retry #$attempts: sleeping $sleep_time seconds"
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
fi
|
fi
|
||||||
eval $*
|
|
||||||
|
P="$1"
|
||||||
|
for param in "${@:2}"; do P="$P '$param'"; done
|
||||||
|
#TODO: replace single quotes in each arg with '"'"' ?
|
||||||
|
bash -c "$P"
|
||||||
return_code=$?
|
return_code=$?
|
||||||
#__log_out "Process returned $return_code on attempt $attempts"
|
#__log_out "Process returned $return_code on attempt $attempts"
|
||||||
if [ $return_code -eq 127 ]; then
|
if [ $return_code -eq 127 ]; then
|
||||||
@ -148,6 +154,6 @@ EOF
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
retry "$max_tries" "$min_sleep" "$max_sleep" "$constant_sleep" "$fail_script" $*
|
retry "$max_tries" "$min_sleep" "$max_sleep" "$constant_sleep" "$fail_script" "$@"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user