Skip to content

Commit c19e3a8

Browse files
committed
retry mechanism
1 parent d89a319 commit c19e3a8

File tree

8 files changed

+49
-67634
lines changed

8 files changed

+49
-67634
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"test": "jest",
11-
"fetch-cosmos-chains": "bash scripts/fetchGrazChains.sh"
11+
"fetch-cosmos-chains": "bash scripts/fetchGrazChain.sh"
1212
},
1313
"dependencies": {
1414
"@amplitude/analytics-browser": "^2.8.1",

scripts/fetchGrazChain.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
4+
MAX_RETRIES=5
5+
6+
7+
command_exists() {
8+
command -v "$1" >/dev/null 2>&1
9+
}
10+
if ! command_exists graz; then
11+
echo "graz is not installed."
12+
if command_exists npm; then
13+
npm install -g graz
14+
else
15+
echo "Error: npm is not installed. Please install npm and try again."
16+
exit 1
17+
fi
18+
fi
19+
20+
fetch_graz_chains() {
21+
local retry_count=0
22+
23+
while [ $retry_count -lt $MAX_RETRIES ]; do
24+
echo "Attempt $((retry_count + 1)) to fetch cosmos chains..."
25+
26+
if graz generate -g; then
27+
echo "Successfully fetched cosmos chains!"
28+
return 0
29+
else
30+
retry_count=$((retry_count + 1))
31+
if [ $retry_count -lt $MAX_RETRIES ]; then
32+
echo "Fetch failed. Retrying in 5 seconds..."
33+
sleep 5
34+
else
35+
echo "Max retries reached. Unable to fetch cosmos chains."
36+
fi
37+
fi
38+
done
39+
40+
return 1
41+
}
42+
43+
if fetch_graz_chains; then
44+
echo "Cosmos chains have been successfully fetched and stored in $OUTPUT_DIR"
45+
else
46+
echo "Failed to fetch cosmos chains after $MAX_RETRIES attempts."
47+
exit 1
48+
fi

store/cosmos-chains/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)