Skip to content

Commit

Permalink
Merge pull request #282 from ava-labs/gstuart/tweak-setup-scripts
Browse files Browse the repository at this point in the history
Minor fixes to local network scripts
  • Loading branch information
geoff-vball authored Feb 13, 2024
2 parents d764aca + c9af9bf commit 250cc1c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docker/run_relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ rm -f $dir_prefix/NETWORK_READY

until cat $dir_prefix/NETWORK_READY &> /dev/null
do
if [[ retry_count -ge 600 ]]; then
if [[ retry_count -ge 300 ]]; then
echo "Subnets didn't start up quickly enough."
exit 1
fi
echo "Waiting for subnets to start up. Retry count: $retry_count"
retry_count=$((retry_count+1))
sleep 1
sleep 2
done

# Source all variables set in run_setup.sh
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy_teleporter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ while [ $# -gt 0 ]; do
--help)
printHelp && exit 0 ;;
*)
echo "Invalid option: -$1" && printHelp && exit 1;;
echo "Invalid option: $1" && printHelp && exit 1;;
esac
shift
done
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ while [ $# -gt 0 ]; do
-h | --help)
printHelp ;;
*)
echo "Invalid option: -$1" && printHelp && exit 1;;
echo "Invalid option: $1" && printHelp && exit 1;;
esac
shift
done
Expand Down
36 changes: 18 additions & 18 deletions scripts/local/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,38 @@ set -e # Stop on first error
source ./scripts/utils.sh
source ./scripts/versions.sh

LOCAL_RELAYER_IMAGE=
RUN_STOP_FLAG="-c"
HELP=
while [ $# -gt 0 ]; do
case "$1" in
-l | --local-relayer-image) LOCAL_RELAYER_IMAGE=$2 ;;
-p | --pause) RUN_STOP_FLAG= ;;
-h | --help) HELP=true ;;
esac
shift
done

if [ "$HELP" = true ]; then
function printHelp {
echo "Usage: ./scripts/local/run.sh [OPTIONS]"
echo "Run Teleporter."
echo ""
echo "Options:"
echo " -l, --local-relayer-image <tag> Use a local AWM Relayer image instead of pulling from dockerhub"
echo " -p, --pause Pause the network on stop. Will attempt to restart the paused network on subsequent runs"
echo " -h, --help Print this help message"
exit 0
fi
}

function cleanup {
echo "Shutting down network before exiting..."
./scripts/local/run_stop.sh $RUN_STOP_FLAG
echo "Network stopped"
}

LOCAL_RELAYER_IMAGE=
RUN_STOP_FLAG="-c"
while [ $# -gt 0 ]; do
case "$1" in
-l | --local-relayer-image) LOCAL_RELAYER_IMAGE=$2 ;;
-p | --pause) RUN_STOP_FLAG= ;;
-h | --help) printHelp && exit 0 ;;
*) echo "Invalid option: $1" && printHelp && exit 1;;
esac
shift
done

# Set up the trap to catch the SIGINT signal (CTRL+C)
# Note that the output of the cleanup function defined in run_setup.sh does not appear if CTRL+C is used to kill this script,
# but the function does in fact run as expected.
trap cleanup SIGTERM
trap cleanup SIGINT
trap cleanup SIGTERM SIGINT

# Set ARCH env so as a container executes without issues in a portable way
# Should be amd64 for linux/macos x86 hosts, and arm64 for macos M1
Expand All @@ -50,6 +48,7 @@ setARCH
if [ -z "$LOCAL_RELAYER_IMAGE" ]; then
echo "Using published awm-relayer image"
docker compose -f docker/docker-compose-run.yml --project-directory ./ up --abort-on-container-exit --build &
docker_pid=$!
else
echo "Using local awm-relayer image: $LOCAL_RELAYER_IMAGE"
if [[ "$(docker images -q awm-relayer:$LOCAL_RELAYER_IMAGE 2> /dev/null)" == "" ]]; then
Expand All @@ -59,6 +58,7 @@ else
rm -f docker/docker-compose-run-local.yml
sed "s/<TAG>/$LOCAL_RELAYER_IMAGE/g" docker/docker-compose-run-local-template.yml > docker/docker-compose-run-local.yml
docker compose -f docker/docker-compose-run-local.yml --project-directory ./ up --abort-on-container-exit --build &
docker_pid=$!
fi

tail -f /dev/null
wait $docker_pid

0 comments on commit 250cc1c

Please sign in to comment.