From f9ebf182e6a61d2107cb3d2393e42ab7f9b2e38a Mon Sep 17 00:00:00 2001 From: Arthur Geron <3487334+arthurgeron@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:59:54 -0300 Subject: [PATCH] feat: fuel core should wait until l1 is healthy --- docker/docker-compose.yml | 9 +++++++-- docker/fuel-core/fuel_core.sh | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4a8b54a07..1f87c3c3d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -13,6 +13,11 @@ services: # expose the service to the host for integration testing - 8545:9545 - ${DEPLOYMENTS_PORT:-8080}:8081 + healthcheck: + test: ["CMD", "curl", "-f", "-H", "Content-Type: application/json", "-d", "{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"net_version\",\"params\":[]}", "http://localhost:9545"] + interval: 5s + timeout: 5s + retries: 10000 networks: - app-network @@ -24,7 +29,7 @@ services: platform: linux/amd64 depends_on: l1_chain: - condition: service_started + condition: service_healthy build: context: ./fuel-core/ environment: @@ -34,7 +39,7 @@ services: # expose the service to the host for integration testing - ${FUEL_CORE_HTTP_PORT:-4000}:4001 healthcheck: - test: curl --fail http://localhost:4001/v1/health || exit 1 + test: ["CMD", "curl", "-f", "http://localhost:4001/v1/health || exit 1"] interval: 10s timeout: 10s retries: 100 diff --git a/docker/fuel-core/fuel_core.sh b/docker/fuel-core/fuel_core.sh index 2a70ba7c2..36702b905 100644 --- a/docker/fuel-core/fuel_core.sh +++ b/docker/fuel-core/fuel_core.sh @@ -16,7 +16,7 @@ fi # wait for the base layer to be up echo "Waiting for l1 chain." -curl \ +until curl \ --fail \ --show-error \ --silent \ @@ -24,8 +24,11 @@ curl \ --retry-connrefused \ --retry $RETRIES \ --retry-delay 1 \ - -d $JSON \ - $L1_CHAIN_HTTP > /dev/null + -d "$JSON" \ + "$L1_CHAIN_HTTP" > /dev/null; do + echo "Waiting for l1 chain..." + sleep 5 +done echo "Connected to l1 chain." # get the deployments file from the deployer