This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c612823
commit df2f4d7
Showing
3 changed files
with
43 additions
and
1 deletion.
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,27 @@ | ||
#!/bin/bash | ||
# parameter 1: url, only GET method supported now | ||
# parameter 2: text needs to be contained | ||
# parameter 3: retry count, if check failed we will wait 1s before next retry, until retry time exceeds retry count | ||
|
||
set -eu | ||
|
||
url=$1 | ||
contain=$2 | ||
retry_count=$3 | ||
|
||
shift 3 | ||
|
||
counter=0 | ||
while [ $counter -lt $retry_count ]; do | ||
got=$(curl -s $url | grep "$contain" | wc -l) | ||
if [[ $got -gt 0 ]]; then | ||
echo "HTTP $url is alive" | ||
exit 0 | ||
fi | ||
((counter+=1)) | ||
echo "wait for HTTP alive for $counter-th time" | ||
sleep 1 | ||
done | ||
|
||
echo "HTTP $url is not alive" | ||
exit 1 |
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