Skip to content

Commit

Permalink
qol improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
klemenfn committed Oct 2, 2024
1 parent 942143e commit c6d9280
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ------------------------------------------------------------------------------
# Build go-flare
# ------------------------------------------------------------------------------
FROM golang:1.18.5 AS flare
FROM golang:1.21 AS flare

WORKDIR /app

Expand All @@ -18,7 +18,7 @@ RUN cd avalanchego && \
# ------------------------------------------------------------------------------
# Build flare-rosetta
# ------------------------------------------------------------------------------
FROM golang:1.18.5 AS rosetta
FROM golang:1.21 AS rosetta

ARG ROSETTA_SRC=https://github.com/flare-foundation/flare-rosetta/archive/refs/heads/main.zip
ARG ROSETTA_SRC_ZIP_SUBFOLDER=flare-rosetta-main
Expand Down Expand Up @@ -50,7 +50,7 @@ RUN \
# ------------------------------------------------------------------------------
# Target container for running the rosetta server
# ------------------------------------------------------------------------------
FROM ubuntu:20.04
FROM ubuntu@sha256:340d9b015b194dc6e2a13938944e0d016e57b9679963fdeb9ce021daac430221

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
14 changes: 13 additions & 1 deletion server/docker/entrypoint_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,43 @@ PID_ENTRYPOINT_FLARE=""

function cleanup ()
{
if kill -0 "$PID_ENTRYPOINT_FLARE"; then
echo "Flare process detected as exited"
fi

if kill -0 "$PID_ENTRYPOINT_ROSETTA"; then
echo "Rosetta process detected as exited"
fi

if [ ! -z "${PID_ENTRYPOINT_ROSETTA}" ]; then echo "Sending KILL to ROSETTA entrypoint (pid:${PID_ENTRYPOINT_ROSETTA})..."; kill -SIGINT ${PID_ENTRYPOINT_ROSETTA}; fi
if [ ! -z "${PID_ENTRYPOINT_FLARE}" ]; then echo "Sending KILL to FLARE entrypoint (pid:${PID_ENTRYPOINT_FLARE})..."; kill -SIGINT ${PID_ENTRYPOINT_FLARE}; fi
}

trap cleanup SIGINT


if [ "$MODE" != "online" ] && [ "$MODE" != "offline" ]; then
echo "An invalid value ('${MODE}') was provided for MODE env variable! Exiting..."
exit 1
fi


if [ "$MODE" = "online" ]; then
echo "Starting flare node in ONLINE mode"
./entrypoint_flare.sh | sed -e 's/^/[go-flare]: /;' &
PID_ENTRYPOINT_FLARE=$!
fi

echo "Starting rosetta server"
./entrypoint_rosetta.sh | sed -e 's/^/[rosetta]: /;' &
PID_ENTRYPOINT_ROSETTA=$!

# Wait for any process to exit
echo "Waiting for either process to exit"
wait -n
EXIT_CODE=$?

echo "Cleaning up and terminating processes due to exit code $EXIT_CODE"

# Attempt to gracefully stop the other process
cleanup

Expand Down
3 changes: 2 additions & 1 deletion server/docker/entrypoint_rosetta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ fi
if [ "$MODE" = "online" ]; then

# Wait for go-flare port to bind
curl ${ROSETTA_FLARE_ENDPOINT} --retry 6 --retry-connrefused --connect-timeout 5 --retry-delay 10 --silent --output /dev/null
sleep 30
curl ${ROSETTA_FLARE_ENDPOINT} --retry 6 --retry-connrefused --retry-all-errors --connect-timeout 5 --retry-delay 10 --silent --output /dev/null

if [ "$START_ROSETTA_SERVER_AFTER_BOOTSTRAP" == "true" ]; then
while true; do
Expand Down

0 comments on commit c6d9280

Please sign in to comment.