Skip to content

Commit

Permalink
fix: wait for agd to stop if it's running
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Mar 13, 2024
1 parent ef32c1d commit f6b824c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions packages/synthetic-chain/public/upgrade-test-scripts/env_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,33 @@ if [[ "$binary" == "agd" ]]; then
sed -i 's/minSubmissionCount": 3/minSubmissionCount": 1/g' "$configdir"/*.json
fi

# XXX race conditions between build stages
await_agd_startable() {
local retries="$1"

local wait="10s"

agd status >/dev/null 2>&1
local exit_code=$?

# If agd is running and we have not reached the maximum number of retries,
# wait and try again
if [[ $exit_code -eq 0 && $retries -gt 0 ]]; then
echo "Waiting $wait for agd to stop"
sleep $wait

wait_and_retry $(($retries - 1))
else
echo "Cannot start agd because it's already running"
return $exit_code
fi
}

startAgd() {
echo "startAgd()"

# XXX debugging https://github.com/Agoric/agoric-3-proposals/issues/93
apt install net-tools
netstat
# precondition check
await_agd_startable 10

agd start --log_level warn "$@" &
AGD_PID=$!
Expand Down

0 comments on commit f6b824c

Please sign in to comment.