From a97b578d4077683573d933ff3980eca71214c3d8 Mon Sep 17 00:00:00 2001 From: LeCoffre Deployment Date: Thu, 25 Sep 2025 18:05:14 +0000 Subject: [PATCH] auto_clea --- .cursor/rules/important.mdc | 8 + AGENTS.md | 2 + AMELIORATIONS_SCRIPTS.md | 111 ++++++++++++++ docs/scripts/URL-HEALTH-CHECKING.md | 40 ++++- scripts/lecoffre_node/start.sh | 222 +++++++++++++++++++++++++++- sdk_storage | 2 +- 6 files changed, 373 insertions(+), 12 deletions(-) create mode 100644 .cursor/rules/important.mdc create mode 100644 AGENTS.md create mode 100644 AMELIORATIONS_SCRIPTS.md diff --git a/.cursor/rules/important.mdc b/.cursor/rules/important.mdc new file mode 100644 index 0000000..bc26a14 --- /dev/null +++ b/.cursor/rules/important.mdc @@ -0,0 +1,8 @@ +--- +description: + +Les règles sont dans IA_agents/ du projet, il faut tout lire ce sont les règles et informations importantes, les prompts sont encore plus important +Au démarrage de ton travail sur un projet suit : IA_agents/prompts/prompt-start.md + +alwaysApply: true +--- diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e60df1d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,2 @@ +Les règles sont dans IA_agents/ du projet, il faut tout lire ce sont les règles et informations importantes, les prompts sont encore plus important +Au démarrage de ton travail sur un projet suit : IA_agents/prompts/prompt-start.md \ No newline at end of file diff --git a/AMELIORATIONS_SCRIPTS.md b/AMELIORATIONS_SCRIPTS.md new file mode 100644 index 0000000..9f5a9c4 --- /dev/null +++ b/AMELIORATIONS_SCRIPTS.md @@ -0,0 +1,111 @@ +# Améliorations des Scripts - LeCoffre Node + +## ✅ **Scripts Améliorés (2025-09-25)** + +### **1. Script `start.sh` - AMÉLIORÉ** + +#### **Nouvelles Fonctionnalités Ajoutées :** + +**🔧 Tests d'URLs Complets Intégrés :** +- ✅ **URLs internes** : 12 services Docker testés +- ✅ **URLs externes** : 6 endpoints publics testés +- ✅ **APIs externes** : 3 endpoints backend testés +- ✅ **WebSockets** : 1 connexion bootstrap testée +- ✅ **Services externes** : 3 dépendances testées +- ✅ **API POST** : Test de l'endpoint IdNot avec données POST + +**📊 Rapport Détaillé :** +- ✅ Compteurs d'URLs accessibles/échouées +- ✅ Support des codes HTTP multiples (200, 301, 302, 307, 308) +- ✅ Timeouts adaptés par type de service +- ✅ Messages d'erreur détaillés + +**🔍 Progression Détaillée Améliorée :** +- ✅ Tests d'URLs internes dans `show_detailed_progress()` +- ✅ Tests d'URLs externes étendus +- ✅ Tests d'APIs externes ajoutés +- ✅ Tests WebSocket améliorés +- ✅ Tests des services externes ajoutés + +#### **URLs Testées (25+ endpoints) :** + +**URLs Internes :** +- `http://localhost:8000/tweaks/1` - BlindBit Oracle API +- `http://localhost:8081/health` - SDK Storage Health +- `http://localhost:8091/` - SDK Relay WebSocket +- `http://localhost:8090/` - SDK Relay HTTP +- `http://localhost:3004/` - LeCoffre Frontend (root) +- `http://localhost:3004/login` - LeCoffre Frontend (login) +- `http://localhost:3004/lecoffre/` - LeCoffre Frontend (app) +- `http://localhost:3003/` - IHM Client +- `http://localhost:3005/api/health` - Grafana Health +- `http://localhost:3005/` - Grafana Dashboard +- `http://localhost:3100/ready` - Loki Health +- `http://localhost:3006/api` - Status API + +**URLs Externes :** +- `https://dev4.4nkweb.com/` - Site Principal +- `https://dev4.4nkweb.com/status/` - Page de Statut +- `https://dev4.4nkweb.com/grafana/` - Dashboard Grafana +- `https://dev4.4nkweb.com/lecoffre/` - Application LeCoffre +- `https://dev4.4nkweb.com/lecoffre/login` - Login LeCoffre +- `https://dev4.4nkweb.com/lecoffre/authorized-client` - Callback d'authentification + +**APIs Externes :** +- `https://dev3.4nkweb.com/api/v1/health` - API Backend Health +- `https://dev3.4nkweb.com/api/v1/status` - API Backend Status +- `https://dev3.4nkweb.com/api/v1/idnot/state` - IdNot State API (POST) + +**WebSockets :** +- `wss://dev3.4nkweb.com/ws/` - Bootstrap Relay + +**Services Externes :** +- `https://mempool2.4nkweb.com/` - Mempool Signet +- `https://qual-connexion.idnot.fr/` - Service IdNot +- `https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1` - IdNot Authorization + +### **2. Documentation `URL-HEALTH-CHECKING.md` - MISE À JOUR** + +#### **Améliorations Apportées :** +- ✅ Ajout d'une section sur les améliorations du script `start.sh` +- ✅ Mise à jour des exemples d'utilisation +- ✅ Documentation des nouvelles fonctionnalités +- ✅ Recommandation d'utiliser `start.sh` comme script principal + +## 🎯 **Résultat Final** + +### **Avant les Améliorations :** +- ❌ Tests d'URLs limités (4 URLs publiques) +- ❌ Pas de tests d'APIs externes +- ❌ Pas de tests WebSocket +- ❌ Pas de tests de services externes +- ❌ Pas de rapport détaillé + +### **Après les Améliorations :** +- ✅ **25+ URLs testées** (internes + externes) +- ✅ **Tests d'APIs complets** (GET + POST) +- ✅ **Tests WebSocket** intégrés +- ✅ **Tests de services externes** (dépendances) +- ✅ **Rapport détaillé** avec compteurs +- ✅ **Support codes HTTP multiples** +- ✅ **Timeouts adaptés** par service + +## 🚀 **Utilisation Recommandée** + +```bash +cd /home/debian/4NK_env/scripts/lecoffre_node +./start.sh +``` + +Ce script unique fournit maintenant : +1. ✅ **Démarrage séquentiel** des services +2. ✅ **Vérification des variables** d'environnement +3. ✅ **Tests complets d'URLs** après stabilisation +4. ✅ **Rapport détaillé** de l'état du système +5. ✅ **Gestion d'erreurs** robuste + +--- + +**Date** : 2025-09-25 +**Statut** : ✅ **Scripts améliorés et documentés** +**Impact** : Script de démarrage unifié avec tests complets diff --git a/docs/scripts/URL-HEALTH-CHECKING.md b/docs/scripts/URL-HEALTH-CHECKING.md index 3dfda9c..dab37a1 100644 --- a/docs/scripts/URL-HEALTH-CHECKING.md +++ b/docs/scripts/URL-HEALTH-CHECKING.md @@ -4,10 +4,33 @@ Ce document décrit les scripts de vérification de santé des URLs pour LeCoffre Node, intégrés dans les processus de backup et de production. +### 🔄 **Mise à jour récente (2025-09-25)** +Le script `start.sh` a été amélioré pour inclure des tests complets d'URLs intégrés au processus de démarrage, offrant une validation complète après le lancement des services. + ## 🔧 Scripts Disponibles -### 1. `url-health-check.sh` -**Script principal de test d'URLs** +### 1. `start.sh` (AMÉLIORÉ) +**Script de démarrage avec tests d'URLs intégrés** + +**Usage :** +```bash +cd /home/debian/4NK_env/scripts/lecoffre_node +./start.sh +``` + +**Nouvelles fonctionnalités (2025-09-25) :** +- ✅ Tests d'URLs complets après démarrage des services +- ✅ Tests des URLs internes (12 services Docker) +- ✅ Tests des URLs externes (6 endpoints publics) +- ✅ Tests des APIs externes (3 endpoints backend) +- ✅ Tests WebSocket (1 connexion bootstrap) +- ✅ Tests des services externes (3 dépendances) +- ✅ Rapport détaillé avec compteurs d'URLs accessibles/échouées +- ✅ Support des codes HTTP multiples (200, 301, 302, 307, 308) +- ✅ Tests API POST pour l'endpoint IdNot + +### 2. `url-health-check.sh` +**Script autonome de test d'URLs** **Usage :** ```bash @@ -164,7 +187,18 @@ cd /home/debian/4NK_env/scripts/lecoffre_node ## 📝 Exemples d'Utilisation -### Test Rapide des URLs +### Démarrage Complet avec Tests d'URLs (RECOMMANDÉ) +```bash +cd /home/debian/4NK_env/scripts/lecoffre_node +./start.sh +``` +**Avantages :** +- Démarre tous les services séquentiellement +- Vérifie les variables d'environnement +- Teste toutes les URLs après stabilisation +- Fournit un rapport complet + +### Test Rapide des URLs (Standalone) ```bash cd /home/debian/4NK_env/scripts/lecoffre_node ./url-health-check.sh diff --git a/scripts/lecoffre_node/start.sh b/scripts/lecoffre_node/start.sh index 6d72700..a32f598 100755 --- a/scripts/lecoffre_node/start.sh +++ b/scripts/lecoffre_node/start.sh @@ -104,6 +104,31 @@ show_detailed_progress() { fi + # URLs internes (Services Docker) + echo -e "${CYAN}Internal URLs Status:${NC}" + local internal_urls=( + "http://localhost:8000/tweaks/1:BlindBit Oracle API" + "http://localhost:8081/health:SDK Storage Health" + "http://localhost:8091/:SDK Relay WebSocket" + "http://localhost:8090/:SDK Relay HTTP" + "http://localhost:3004/:LeCoffre Frontend" + "http://localhost:3003/:IHM Client" + "http://localhost:3005/api/health:Grafana Health" + "http://localhost:3100/ready:Loki Health" + "http://localhost:3006/api:Status API" + ) + + for url_entry in "${internal_urls[@]}"; do + local url="${url_entry%%:*}" + local name="${url_entry##*:}" + local response=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "$url" 2>/dev/null || echo "000") + if [[ "$response" =~ ^(200|301|302|307|308)$ ]]; then + echo -e " ${GREEN}$name: Accessible (HTTP $response)${NC}" + else + echo -e " ${YELLOW}$name: Not accessible (HTTP $response)${NC}" + fi + done + # URLs publiques HTTPS echo -e "${CYAN}Public URLs Status:${NC}" local urls=( @@ -111,12 +136,32 @@ show_detailed_progress() { "https://dev4.4nkweb.com/grafana/:Grafana Dashboard" "https://dev4.4nkweb.com/:Main Site" "https://dev4.4nkweb.com/lecoffre/:LeCoffre App" + "https://dev4.4nkweb.com/lecoffre/login:LeCoffre Login" + "https://dev4.4nkweb.com/lecoffre/authorized-client:Auth Callback" ) for url_entry in "${urls[@]}"; do local url="${url_entry%%:*}" local name="${url_entry##*:}" - local response=$(curl -s -o /dev/null -w '%{http_code}' "$url" 2>/dev/null || echo "000") + local response=$(curl -s -o /dev/null -w '%{http_code}' --max-time 10 "$url" 2>/dev/null || echo "000") + if [[ "$response" =~ ^(200|301|302|307|308)$ ]]; then + echo -e " ${GREEN}$name: Accessible (HTTP $response)${NC}" + else + echo -e " ${YELLOW}$name: Not accessible (HTTP $response)${NC}" + fi + done + + # APIs externes + echo -e "${CYAN}External APIs Status:${NC}" + local api_urls=( + "https://dev3.4nkweb.com/api/v1/health:Backend Health" + "https://dev3.4nkweb.com/api/v1/status:Backend Status" + ) + + for url_entry in "${api_urls[@]}"; do + local url="${url_entry%%:*}" + local name="${url_entry##*:}" + local response=$(curl -s -o /dev/null -w '%{http_code}' --max-time 10 "$url" 2>/dev/null || echo "000") if [ "$response" = "200" ]; then echo -e " ${GREEN}$name: Accessible (HTTP $response)${NC}" else @@ -124,11 +169,22 @@ show_detailed_progress() { fi done + # Test API IdNot avec POST + echo -e "${CYAN}Testing IdNot API:${NC}" + local idnot_response=$(curl -s -o /dev/null -w '%{http_code}' --max-time 10 -X POST \ + -H "Content-Type: application/json" \ + -d '{"next_url":"https://dev4.4nkweb.com/authorized-client"}' \ + "https://dev3.4nkweb.com/api/v1/idnot/state" 2>/dev/null || echo "000") + if [ "$idnot_response" = "200" ]; then + echo -e " ${GREEN}IdNot State API: Accessible (HTTP $idnot_response)${NC}" + else + echo -e " ${YELLOW}IdNot State API: Not accessible (HTTP $idnot_response)${NC}" + fi + # URLs WebSocket publiques echo -e "${CYAN}WebSocket URLs Status:${NC}" local ws_urls=( "wss://dev3.4nkweb.com/ws/:Bootstrap Relay" - "wss://dev3.4nkweb.com/ws/:Signer Service" ) for ws_entry in "${ws_urls[@]}"; do @@ -143,6 +199,25 @@ show_detailed_progress() { fi done + # Services externes (dépendances) + echo -e "${CYAN}External Services Status:${NC}" + local external_urls=( + "https://mempool2.4nkweb.com/:Mempool Signet" + "https://qual-connexion.idnot.fr/:IdNot Service" + "https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1:IdNot Auth" + ) + + for url_entry in "${external_urls[@]}"; do + local url="${url_entry%%:*}" + local name="${url_entry##*:}" + local response=$(curl -s -o /dev/null -w '%{http_code}' --max-time 10 "$url" 2>/dev/null || echo "000") + if [[ "$response" =~ ^(200|301|302|307|308)$ ]]; then + echo -e " ${GREEN}$name: Accessible (HTTP $response)${NC}" + else + echo -e " ${YELLOW}$name: Not accessible (HTTP $response)${NC}" + fi + done + echo -e "${CYAN}========================${NC}" } @@ -256,7 +331,7 @@ start_service() { fi print_message "Starting $display_name..." - if ! docker compose --env-file /home/debian/4NK_env/.env.master up -d "$service_name"; then + if ! docker compose --env-file /home/debian/4NK_env/.env.master -f /home/debian/4NK_env/lecoffre_node/docker-compose.yml up -d "$service_name"; then echo -e "${YELLOW}⚠ Failed to start $display_name, continuing with next service...${NC}" return 0 fi @@ -291,7 +366,7 @@ echo # Arrêter les services existants print_message "Stopping existing services..." -docker compose --env-file /home/debian/4NK_env/.env.master down --remove-orphans >/dev/null 2>&1 || true +docker compose --env-file /home/debian/4NK_env/.env.master -f /home/debian/4NK_env/lecoffre_node/docker-compose.yml down --remove-orphans >/dev/null 2>&1 || true # Ordre de démarrage logique services=( @@ -320,11 +395,142 @@ for service in "${services[@]}"; do echo done +# Attendre un peu pour que tous les services se stabilisent +print_message "Waiting for services to stabilize..." +sleep 30 + +# Test complet des URLs +echo -e "${BLUE}========================================${NC}" +echo -e "${BLUE} Comprehensive URL Tests${NC}" +echo -e "${BLUE}========================================${NC}" +echo + +# Compteurs pour les tests d'URLs +TOTAL_URLS=0 +ACCESSIBLE_URLS=0 +FAILED_URLS=0 + +# Fonction pour tester une URL avec comptage +test_url_with_count() { + local url="$1" + local description="$2" + local expected_codes="${3:-200}" + local timeout="${4:-10}" + + TOTAL_URLS=$((TOTAL_URLS + 1)) + + print_message "Testing: $description" + echo -e " ${CYAN}URL: $url${NC}" + + local response=$(curl -s -o /dev/null -w '%{http_code}' --max-time "$timeout" "$url" 2>/dev/null || echo "000") + + if [[ "$response" =~ ^($expected_codes)$ ]]; then + echo -e " ${GREEN}✓${NC} Status: HTTP $response - Accessible" + ACCESSIBLE_URLS=$((ACCESSIBLE_URLS + 1)) + return 0 + else + echo -e " ${RED}✗${NC} Status: HTTP $response - Not accessible" + FAILED_URLS=$((FAILED_URLS + 1)) + return 1 + fi +} + +# Tests des URLs internes +echo -e "${CYAN}=== URLs INTERNES (Services Docker) ===${NC}" +test_url_with_count "http://localhost:8000/tweaks/1" "BlindBit Oracle API" "200" 5 +test_url_with_count "http://localhost:8081/health" "SDK Storage Health" "200" 5 +test_url_with_count "http://localhost:8091/" "SDK Relay WebSocket" "200" 5 +test_url_with_count "http://localhost:8090/" "SDK Relay HTTP" "200" 5 +test_url_with_count "http://localhost:3004/" "LeCoffre Frontend (root)" "200|301|302|307|308" 10 +test_url_with_count "http://localhost:3004/login" "LeCoffre Frontend (login)" "200|301|302|307|308" 10 +test_url_with_count "http://localhost:3004/lecoffre/" "LeCoffre Frontend (app)" "200|301|302|307|308" 10 +test_url_with_count "http://localhost:3003/" "IHM Client" "200" 10 +test_url_with_count "http://localhost:3005/api/health" "Grafana Health" "200" 5 +test_url_with_count "http://localhost:3005/" "Grafana Dashboard" "200|301|302" 10 +test_url_with_count "http://localhost:3100/ready" "Loki Health" "200" 5 +test_url_with_count "http://localhost:3006/api" "Status API" "200" 5 +echo + +# Tests des URLs externes +echo -e "${CYAN}=== URLs EXTERNES (Domaine Public) ===${NC}" +test_url_with_count "https://dev4.4nkweb.com/" "Site Principal" "200|301|302" 15 +test_url_with_count "https://dev4.4nkweb.com/status/" "Page de Statut" "200" 15 +test_url_with_count "https://dev4.4nkweb.com/grafana/" "Dashboard Grafana" "200|301|302" 15 +test_url_with_count "https://dev4.4nkweb.com/lecoffre/" "Application LeCoffre" "200|301|302" 15 +test_url_with_count "https://dev4.4nkweb.com/lecoffre/login" "Login LeCoffre" "200|301|302" 15 +test_url_with_count "https://dev4.4nkweb.com/lecoffre/authorized-client" "Callback d'authentification" "200|301|302" 15 +echo + +# Tests des APIs externes +echo -e "${CYAN}=== APIs EXTERNES (Backend Services) ===${NC}" +test_url_with_count "https://dev3.4nkweb.com/api/v1/health" "API Backend Health" "200" 10 +test_url_with_count "https://dev3.4nkweb.com/api/v1/status" "API Backend Status" "200" 10 + +# Test API IdNot avec POST +print_message "Testing API POST: IdNot State Endpoint" +echo -e " ${CYAN}URL: https://dev3.4nkweb.com/api/v1/idnot/state${NC}" +echo -e " ${CYAN}Data: {\"next_url\":\"https://dev4.4nkweb.com/authorized-client\"}${NC}" + +TOTAL_URLS=$((TOTAL_URLS + 1)) +local idnot_response=$(curl -s -o /dev/null -w '%{http_code}' --max-time 10 -X POST \ + -H "Content-Type: application/json" \ + -d '{"next_url":"https://dev4.4nkweb.com/authorized-client"}' \ + "https://dev3.4nkweb.com/api/v1/idnot/state" 2>/dev/null || echo "000") + +if [ "$idnot_response" = "200" ]; then + echo -e " ${GREEN}✓${NC} Status: HTTP $idnot_response - API accessible" + ACCESSIBLE_URLS=$((ACCESSIBLE_URLS + 1)) +else + echo -e " ${RED}✗${NC} Status: HTTP $idnot_response - API not accessible" + FAILED_URLS=$((FAILED_URLS + 1)) +fi +echo + +# Tests des WebSockets externes +echo -e "${CYAN}=== WebSockets Externes ===${NC}" +print_message "Testing WebSocket: Bootstrap Relay" +echo -e " ${CYAN}URL: wss://dev3.4nkweb.com/ws/${NC}" + +TOTAL_URLS=$((TOTAL_URLS + 1)) +local ws_test=$(timeout 5 wscat -c "wss://dev3.4nkweb.com/ws/" --no-color 2>/dev/null && echo "connected" || echo "failed") + +if [ "$ws_test" = "connected" ]; then + echo -e " ${GREEN}✓${NC} Status: Connected" + ACCESSIBLE_URLS=$((ACCESSIBLE_URLS + 1)) +else + echo -e " ${RED}✗${NC} Status: Not connected" + FAILED_URLS=$((FAILED_URLS + 1)) +fi +echo + +# Tests des services externes +echo -e "${CYAN}=== Services Externes (Dépendances) ===${NC}" +test_url_with_count "https://mempool2.4nkweb.com/" "Mempool Signet" "200|301|302" 10 +test_url_with_count "https://qual-connexion.idnot.fr/" "Service IdNot" "200|301|302" 10 +test_url_with_count "https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1" "IdNot Authorization" "200|301|302" 10 +echo + +# Résumé final des tests d'URLs +echo -e "${CYAN}=== RÉSUMÉ DES TESTS D'URLs ===${NC}" +echo -e "${BLUE}Total URLs testées: $TOTAL_URLS${NC}" +echo -e "${GREEN}URLs accessibles: $ACCESSIBLE_URLS${NC}" +echo -e "${RED}URLs échouées: $FAILED_URLS${NC}" + +if [ $FAILED_URLS -eq 0 ]; then + echo -e "${GREEN}🎉 Toutes les URLs sont accessibles !${NC}" +elif [ $FAILED_URLS -lt $((TOTAL_URLS / 2)) ]; then + echo -e "${YELLOW}⚠️ Certaines URLs ne sont pas accessibles, mais la majorité fonctionne.${NC}" +else + echo -e "${RED}❌ Trop d'URLs ne sont pas accessibles. Vérifiez la configuration.${NC}" +fi + +echo + # Afficher le statut final echo -e "${GREEN}🎉 All services started successfully!${NC}" echo echo -e "${BLUE}Final status:${NC}" -docker compose --env-file /home/debian/4NK_env/.env.master ps +docker compose --env-file /home/debian/4NK_env/.env.master -f /home/debian/4NK_env/lecoffre_node/docker-compose.yml ps # Calculer le temps total end_time=$(date +%s) @@ -336,7 +542,7 @@ echo echo -e "${GREEN}Total startup time: ${minutes}m ${seconds}s${NC}" echo echo -e "${BLUE}Useful commands:${NC}" -echo -e " ${YELLOW}docker compose --env-file /home/debian/4NK_env/.env.master logs -f${NC} # Voir les logs" -echo -e " ${YELLOW}docker compose --env-file /home/debian/4NK_env/.env.master down${NC} # Arrêter les services" -echo -e " ${YELLOW}docker compose --env-file /home/debian/4NK_env/.env.master ps${NC} # Voir le statut" +echo -e " ${YELLOW}docker compose --env-file /home/debian/4NK_env/.env.master -f /home/debian/4NK_env/lecoffre_node/docker-compose.yml logs -f${NC} # Voir les logs" +echo -e " ${YELLOW}docker compose --env-file /home/debian/4NK_env/.env.master -f /home/debian/4NK_env/lecoffre_node/docker-compose.yml down${NC} # Arrêter les services" +echo -e " ${YELLOW}docker compose --env-file /home/debian/4NK_env/.env.master -f /home/debian/4NK_env/lecoffre_node/docker-compose.yml ps${NC} # Voir le statut" echo diff --git a/sdk_storage b/sdk_storage index 06879e4..7b6f77c 160000 --- a/sdk_storage +++ b/sdk_storage @@ -1 +1 @@ -Subproject commit 06879e4fed871b589814a1fc424c87054950c202 +Subproject commit 7b6f77cb89af34872a47ed7b8444d1cf1206b053