Implement comprehensive healthcheck for sdk_relay - Add custom healthcheck script that tests: process, WebSocket port, connectivity, configuration - Update Dockerfile with required tools (net-tools, procps) - Add healthcheck test script for manual verification - Update documentation with healthcheck details - Fix healthcheck configuration in docker-compose.yml

This commit is contained in:
Nicolas Cantu 2025-08-22 14:31:55 +02:00
parent 948476b784
commit 926013b86e
5 changed files with 137 additions and 3 deletions

View File

@ -115,6 +115,9 @@ cd sdk_relay
# Débogage du container sdk_relay
./debug_container.sh
# Test du healthcheck sdk_relay
./test_healthcheck.sh
# Logs des services
sudo docker-compose logs [service_name]
```
@ -142,6 +145,25 @@ sudo docker-compose ps
sudo docker-compose logs | grep health
```
#### Healthcheck sdk_relay
Le service sdk_relay utilise un healthcheck personnalisé qui vérifie :
- ✅ **Processus** : sdk_relay en cours d'exécution
- ✅ **Port WebSocket** : Port 8090 en écoute
- ✅ **Connectivité Bitcoin Core** : Accès au RPC Bitcoin
- ✅ **Connectivité Blindbit** : Accès au service Blindbit
- ✅ **Configuration** : Fichier de configuration présent
- ✅ **Cookie Bitcoin** : Authentification Bitcoin configurée
```bash
# Test manuel du healthcheck
sudo docker exec sdk_relay /usr/local/bin/healthcheck.sh
# Test depuis l'hôte
cd sdk_relay && ./test_healthcheck.sh
```
### Logs
```bash

View File

@ -103,10 +103,11 @@ services:
echo 'Starting sdk_relay:' &&
/usr/local/bin/sdk_relay --config .conf"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8091/health"]
test: ["CMD", "/usr/local/bin/healthcheck.sh"]
interval: 30s
timeout: 10s
timeout: 15s
retries: 3
start_period: 60s
volumes:
bitcoin_data:

View File

@ -20,6 +20,8 @@ RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
strace \
net-tools \
procps \
&& rm -rf /var/lib/apt/lists/*
# Copier le binaire
@ -35,8 +37,9 @@ WORKDIR /home/bitcoin
# Créer le répertoire de données
RUN mkdir -p /home/bitcoin/.4nk
# Copier la configuration
# Copier la configuration et le script de healthcheck
COPY 4NK_node/sdk_relay/.conf /home/bitcoin/.conf
COPY 4NK_node/sdk_relay/healthcheck.sh /usr/local/bin/healthcheck.sh
# Changer les permissions
RUN chown -R bitcoin:bitcoin /home/bitcoin

61
sdk_relay/healthcheck.sh Executable file
View File

@ -0,0 +1,61 @@
#!/bin/bash
# Script de healthcheck pour sdk_relay
set -e
# Test 1: Vérifier que le processus sdk_relay est en cours d'exécution
echo "🔍 Test 1: Processus sdk_relay"
if pgrep -f "sdk_relay" > /dev/null; then
echo "✅ Processus sdk_relay en cours d'exécution"
else
echo "❌ Processus sdk_relay non trouvé"
exit 1
fi
# Test 2: Vérifier que le port WebSocket écoute
echo "🔍 Test 2: Port WebSocket"
if netstat -tuln | grep ":8090 " | grep "LISTEN" > /dev/null; then
echo "✅ Port 8090 écoute"
else
echo "❌ Port 8090 n'écoute pas"
exit 1
fi
# Test 3: Vérifier la connectivité Bitcoin Core
echo "🔍 Test 3: Connectivité Bitcoin Core"
if curl -s --connect-timeout 5 http://bitcoin:18443 > /dev/null 2>&1; then
echo "✅ Bitcoin Core accessible"
else
echo "❌ Bitcoin Core inaccessible"
exit 1
fi
# Test 4: Vérifier la connectivité Blindbit
echo "🔍 Test 4: Connectivité Blindbit"
if curl -s --connect-timeout 5 http://blindbit:8000 > /dev/null 2>&1; then
echo "✅ Blindbit accessible"
else
echo "❌ Blindbit inaccessible"
exit 1
fi
# Test 5: Vérifier que le fichier de configuration existe
echo "🔍 Test 5: Configuration"
if [ -f "/home/bitcoin/.conf" ]; then
echo "✅ Fichier de configuration présent"
else
echo "❌ Fichier de configuration manquant"
exit 1
fi
# Test 6: Vérifier que le cookie Bitcoin existe
echo "🔍 Test 6: Cookie Bitcoin"
if [ -f "/home/bitcoin/.4nk/bitcoin.cookie" ]; then
echo "✅ Cookie Bitcoin présent"
else
echo "❌ Cookie Bitcoin manquant"
exit 1
fi
echo "🎯 Tous les tests de santé sont passés !"
exit 0

47
sdk_relay/test_healthcheck.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# Script de test pour le healthcheck de sdk_relay
set -e
echo "🔍 Test du healthcheck sdk_relay..."
echo ""
# Test 1: Vérifier que le script de healthcheck existe
echo "📡 Test 1: Script de healthcheck"
if [ -f "healthcheck.sh" ]; then
echo "✅ Script healthcheck.sh présent"
else
echo "❌ Script healthcheck.sh manquant"
exit 1
fi
# Test 2: Vérifier que le script est exécutable
echo ""
echo "📡 Test 2: Permissions du script"
if [ -x "healthcheck.sh" ]; then
echo "✅ Script healthcheck.sh exécutable"
else
echo "❌ Script healthcheck.sh non exécutable"
exit 1
fi
# Test 3: Tester le healthcheck dans le container (si sdk_relay est en cours d'exécution)
echo ""
echo "📡 Test 3: Healthcheck dans le container"
if sudo docker ps | grep -q "sdk_relay"; then
echo "Container sdk_relay trouvé, test du healthcheck..."
if sudo docker exec sdk_relay /usr/local/bin/healthcheck.sh; then
echo "✅ Healthcheck réussi dans le container"
else
echo "❌ Healthcheck échoué dans le container"
exit 1
fi
else
echo "⚠️ Container sdk_relay non trouvé, test du healthcheck ignoré"
fi
echo ""
echo "🎯 Test du healthcheck terminé avec succès !"
echo ""
echo "💡 Pour tester manuellement :"
echo " sudo docker exec sdk_relay /usr/local/bin/healthcheck.sh"