-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update bigdipper scripts and services
- Loading branch information
1 parent
7300c3a
commit 2be854d
Showing
4 changed files
with
150 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...deployment/bigdipper/ag-bigdipper.service → ...yment/bigdipper/bigdipper-testnet.service
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
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,58 @@ | ||
#! /bin/bash | ||
# bigdipper.sh - Run Agoric Big Dipper Explorer | ||
set -e | ||
|
||
# Kill off all our children on exit. | ||
trap 'kill $(jobs -p) 2>/dev/null' EXIT | ||
|
||
NETWORK_URL=${1-"https://testnet.agoric.com"} | ||
ncf=`curl -Ss "$NETWORK_URL/network-config"` | ||
cn=`echo "$ncf" | jq -r '.chainName'` | ||
|
||
origRpcAddrs=( $(echo $ncf | jq -r '.rpcAddrs | join(" ")' ) ) | ||
|
||
rpcAddrs=(${origRpcAddrs[@]}) | ||
rp= | ||
while [[ ${#rpcAddrs[@]} -gt 0 ]]; do | ||
r=$(( $RANDOM % ${#rpcAddrs[@]} )) | ||
selected=${rpcAddrs[$r]} | ||
rpcAddrs=( ${rpcAddrs[@]/$selected} ) | ||
|
||
ping="curl -s http://$selected/status" | ||
if $ping > /dev/null; then | ||
# Found an active node. | ||
rp=$selected | ||
break | ||
fi | ||
done | ||
|
||
if test -z "$rp"; then | ||
echo "Cannot find an active node; last tried $selected" | ||
sleep 20 | ||
exit 1 | ||
fi | ||
|
||
# Network name vs. database name. | ||
nn=`echo "$cn" | sed -e 's/-[0-9].*//'` | ||
db=`echo "$cn" | sed -e 's/\./-/g'` | ||
|
||
export MONGO_URL=mongodb://localhost:27017/"$db" | ||
GTM=`cat google-tag-manager.txt || true` | ||
|
||
api=`echo "$rp" | sed -e 's/\:.*/:1317/'` | ||
|
||
test -d "portal-$cn" && ln -sfT "portal-$cn" "portal-$nn" | ||
cd "portal-$nn" | ||
export METEOR_SETTINGS=`sed -e "s/@GTM@/$GTM/; s/@CHAIN_NAME@/$cn/; s!@NETWORK_URL@!$NETWORK_URL!; s/@RPC@/$rp/; s/@API@/$api/;" settings.json` | ||
|
||
# Kill this script if the ping fails. | ||
# Systemd restarts us and we refresh our parameters. | ||
{ | ||
while $ping > /dev/null; do | ||
sleep 30 | ||
done | ||
kill $$ | ||
} & | ||
|
||
/usr/bin/node main.js | ||
exit $? |