-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run `fiopush` and `fiocheck` commands with up to 3 attempts. Signed-off-by: Mike Sul <[email protected]>
- Loading branch information
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
HERE=$(dirname $(readlink -f $0)) | ||
CHECK_BIN="${FIO_CHECK_BIN-/usr/bin/fiocheck}" | ||
|
||
"${HERE}/run-with-retry.sh" "${CHECK_BIN}" $@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
HERE=$(dirname $(readlink -f $0)) | ||
PUSH_BIN="${FIO_PUSH_BIN-/usr/bin/fiopush}" | ||
|
||
"${HERE}/run-with-retry.sh" "${PUSH_BIN}" $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
num_attempts=3 | ||
|
||
# Check if at least one argument is provided, the first argument is treated | ||
# as the command to execute. | ||
if [[ $# -lt 1 ]]; then | ||
echo "Usage: $0 <command> [args...]" | ||
exit 1 | ||
fi | ||
|
||
command=$1 | ||
shift # Shift out the command | ||
|
||
# Track the attempt count | ||
attempt=1 | ||
|
||
# Try to execute the command with retries | ||
while [[ $attempt -le $num_attempts ]]; do | ||
echo "Attempt $attempt/$num_attempts: Running '$command $@'" | ||
$command "$@" | ||
|
||
# Check if the command succeeded | ||
if [[ $? -eq 0 ]]; then | ||
echo "Command succeeded on attempt #$attempt" | ||
exit 0 | ||
fi | ||
|
||
echo "Command failed on attempt #$attempt. Retrying..." | ||
attempt=$((attempt + 1)) | ||
done | ||
|
||
echo "Command failed after $num_attempts attempts." | ||
exit 1 |