Skip to content

Commit

Permalink
fix: improve service initialization reliability
Browse files Browse the repository at this point in the history
- Add proper health checks for relay service
- Fix double service start in entrypoint.sh
- Improve doichaind readiness check
- Add proper service dependency order

Co-Authored-By: Nico Krause <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and silkroadnomad committed Dec 23, 2024
1 parent d2f527e commit ce3289b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ services:
- ./docker/entrypoint.sh:/usr/src/app/entrypoint.sh
# - ./:/usr/src/app/
entrypoint: ["/usr/src/app/entrypoint.sh", "generate-key"]
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "3000"]
interval: 5s
timeout: 3s
retries: 3
depends_on:
- electrumx
- regtest
Expand Down
11 changes: 4 additions & 7 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ wait_for_services() {
done
echo "ElectrumX and regtest are ready!"

# Start the relay service
npm run start &

# Then wait for relay service to be ready
count=0
echo "Starting relay service..."
npm run start &

echo "Waiting for relay service to initialize..."
while ! check_relay_service; do
count=$((count + 1))
Expand Down Expand Up @@ -74,10 +74,7 @@ if [ "$1" == "generate-key" ]; then
cat .env

# Wait for all services to be ready before starting
if wait_for_services; then
echo "Starting relay service..."
npm run start
else
if ! wait_for_services; then
echo "Failed to connect to required services"
exit 1
fi
Expand Down
8 changes: 6 additions & 2 deletions docker/regtest-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ set -e
echo "Starting doichaind in regtest mode..."
doichaind -regtest -daemon

echo "Waiting 5s for doichaind to be ready..."
sleep 5
echo "Waiting for doichaind to be ready..."
while ! doichain-cli -regtest -rpcuser=admin -rpcpassword=adminpw -rpcwait getblockchaininfo > /dev/null 2>&1; do
echo "Waiting for doichaind..."
sleep 1
done
echo "doichaind is ready!"

echo "Generating a new address..."
NEWADDR=$(doichain-cli -regtest -rpcuser=admin -rpcpassword=adminpw -rpcwait getnewaddress)
Expand Down

0 comments on commit ce3289b

Please sign in to comment.