**Motivations:** - Export Signet and mining wallet backups to git with only 2 versions kept - Document and add backup/restore scripts for signet and mining wallet **Correctifs:** - Backup-to-git uses SSH URL for passwordless cron; copy timestamped files only; prune to 2 versions; remove *-latest from backup repo **Evolutions:** - data/backup-to-git-cron.sh: daily export to git.4nkweb.com/4nk/backup - save-signet-datadir-backup.sh, restore-signet-from-backup.sh, export-mining-wallet.sh, import-mining-wallet.sh - features/backup-to-git-daily-cron.md, docs/MAINTENANCE.md backup section - .gitignore: data/backup-to-git.log **Pages affectées:** - .gitignore, data/backup-to-git-cron.sh, docs/MAINTENANCE.md, features/backup-to-git-daily-cron.md - save-signet-datadir-backup.sh, restore-signet-from-backup.sh, export-mining-wallet.sh, import-mining-wallet.sh - Plus autres fichiers modifiés ou non suivis déjà présents dans le working tree
89 lines
2.9 KiB
Markdown
89 lines
2.9 KiB
Markdown
# Fix: Mempool API Healthcheck - curl not found
|
|
|
|
**Date:** 2026-01-27
|
|
**Auteur:** Équipe 4NK
|
|
|
|
## Problème
|
|
|
|
Le conteneur Docker `mempool_api_1` était marqué comme "unhealthy" avec un FailingStreak de 2963 échecs consécutifs.
|
|
|
|
### Symptômes
|
|
|
|
- Statut Docker: `unhealthy`
|
|
- Erreur répétée: `/bin/sh: 1: curl: not found`
|
|
- Le healthcheck ne pouvait pas s'exécuter car `curl` n'est pas installé dans l'image `mempool/backend:latest`
|
|
|
|
### Impact
|
|
|
|
- Le conteneur fonctionnait normalement (les logs montraient une synchronisation correcte des index Bitcoin)
|
|
- Le statut "unhealthy" générait des alertes et masquait l'état réel du service
|
|
- Pas d'impact fonctionnel direct, mais confusion sur l'état réel du service
|
|
|
|
## Root cause
|
|
|
|
Le healthcheck dans `docker-compose.signet.yml` utilisait la commande `curl` qui n'est pas disponible dans l'image Docker `mempool/backend:latest`. L'image ne contient que les dépendances minimales nécessaires au backend Node.js.
|
|
|
|
## Correctifs
|
|
|
|
### Modification du healthcheck
|
|
|
|
**Fichier modifié:** `mempool/docker-compose.signet.yml`
|
|
|
|
**Avant:**
|
|
```yaml
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -f http://localhost:8999/api/v1/backend-info | grep -q . || exit 1"]
|
|
```
|
|
|
|
**Après:**
|
|
```yaml
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "node -e \"require('http').get('http://localhost:8999/api/v1/backend-info', (r) => { process.exit(r.statusCode === 200 ? 0 : 1); }).on('error', () => process.exit(1));\""]
|
|
```
|
|
|
|
### Justification
|
|
|
|
- `node` est disponible dans l'image (backend Node.js)
|
|
- Utilisation de l'API HTTP native de Node.js au lieu de `curl`
|
|
- Même logique de vérification: requête HTTP vers `/api/v1/backend-info` avec vérification du code de statut 200
|
|
|
|
## Modifications
|
|
|
|
- `mempool/docker-compose.signet.yml`: Modification du healthcheck du service `api`
|
|
|
|
## Modalités de déploiement
|
|
|
|
1. Modifier le fichier `docker-compose.signet.yml`
|
|
2. Recréer le conteneur pour appliquer la nouvelle configuration:
|
|
```bash
|
|
cd /srv/4NK/mempool.4nkweb.com
|
|
docker-compose -f docker-compose.signet.yml up -d --force-recreate api
|
|
```
|
|
3. Vérifier que le healthcheck passe à "healthy" après le délai de démarrage (40s)
|
|
|
|
## Modalités d'analyse
|
|
|
|
### Vérification du statut
|
|
|
|
```bash
|
|
docker inspect mempool_api_1 --format='{{.State.Health.Status}}'
|
|
```
|
|
|
|
### Vérification des logs du healthcheck
|
|
|
|
```bash
|
|
docker inspect mempool_api_1 --format='{{json .State.Health}}' | python3 -m json.tool
|
|
```
|
|
|
|
### Test manuel du healthcheck
|
|
|
|
```bash
|
|
docker exec mempool_api_1 node -e "require('http').get('http://localhost:8999/api/v1/backend-info', (r) => { console.log('Status:', r.statusCode); process.exit(r.statusCode === 200 ? 0 : 1); }).on('error', (e) => { console.error('Error:', e.message); process.exit(1); });"
|
|
```
|
|
|
|
## Résultat
|
|
|
|
- Le conteneur `mempool_api_1` est maintenant marqué comme "healthy"
|
|
- Le healthcheck fonctionne correctement avec Node.js
|
|
- Aucun impact sur le fonctionnement du service
|