**Motivations:** - Prevent bitcoind crashes caused by heavy RPC calls without timeout - Document bitcoind crash and wallet loading stuck issues - Clean up obsolete files (configure-nginx-proxy.sh, userwallet components, website-skeleton, old fixKnowledge docs) **Root causes:** - RPC calls without timeout causing bitcoind crashes - No pre-check of bitcoind health before heavy operations - Large wallet (315MB) causing long loading times and potential hangs - Missing retry mechanism for transient errors **Correctifs:** - Add timeouts on RPC calls (5 minutes for listunspent, 10 seconds for healthcheck) - Add bitcoind health check before synchronization - Implement retry with exponential backoff - Reduce maximumCount limit from 9999999 to 500000 UTXOs - Improve cron script with pre-checks and better error handling - Add container status verification before script execution **Evolutions:** - New check-services-status.sh script for service diagnostics - Documentation of crash issues in fixKnowledge - Improved logging with timestamps - Better error messages and handling **Pages affectées:** - data/sync-utxos-spent-status.mjs - data/sync-utxos-cron.sh - data/restart-services-cron.sh - data/check-services-status.sh (new) - fixKnowledge/sync-utxos-rpc-optimization.md (new) - fixKnowledge/signet-bitcoind-crash-mining-stopped.md (new) - fixKnowledge/signet-bitcoind-crash-wallet-loading-stuck.md (new) - Removed obsolete files: configure-nginx-proxy.sh, userwallet components, website-skeleton files, old fixKnowledge docs Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.7 KiB
Bash
Executable File
52 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
# Script de synchronisation des UTXOs dépensés
|
||
# À exécuter via cron pour maintenir la synchronisation
|
||
# Vérifie que bitcoind est disponible avant d'exécuter la synchronisation
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||
LOG_FILE="$SCRIPT_DIR/sync-utxos.log"
|
||
BITCOIND_CONTAINER="bitcoin-signet-instance"
|
||
|
||
log() {
|
||
echo "$(date -Iseconds) $*" | tee -a "$LOG_FILE"
|
||
}
|
||
|
||
cd "$PROJECT_DIR" || exit 1
|
||
|
||
log "=== Synchronisation des UTXOs dépensés ==="
|
||
|
||
# Vérifier que bitcoind est disponible avant de commencer
|
||
if docker ps -q -f "name=^${BITCOIND_CONTAINER}$" 2>/dev/null | grep -q .; then
|
||
log "Vérification de la disponibilité de bitcoind..."
|
||
if docker exec "$BITCOIND_CONTAINER" bitcoin-cli -datadir=/root/.bitcoin getblockchaininfo &>/dev/null; then
|
||
log " ✅ Bitcoind disponible, démarrage de la synchronisation..."
|
||
else
|
||
log " ❌ Bitcoind ne répond pas (RPC non disponible)"
|
||
log " ⚠️ Arrêt de la synchronisation pour éviter de surcharger bitcoind"
|
||
log " ℹ️ Le script sera réexécuté à la prochaine heure"
|
||
exit 1
|
||
fi
|
||
else
|
||
log " ❌ Conteneur bitcoind non trouvé ou arrêté"
|
||
log " ⚠️ Arrêt de la synchronisation"
|
||
exit 1
|
||
fi
|
||
|
||
# Exécuter le script de synchronisation
|
||
log "Exécution du script de synchronisation..."
|
||
node "$SCRIPT_DIR/sync-utxos-spent-status.mjs" >> "$LOG_FILE" 2>&1
|
||
EXIT_CODE=$?
|
||
|
||
if [ $EXIT_CODE -eq 0 ]; then
|
||
log "✅ Synchronisation terminée avec succès"
|
||
else
|
||
log "❌ Synchronisation échouée (code: $EXIT_CODE)"
|
||
fi
|
||
|
||
# Garder seulement les 100 dernières lignes du log
|
||
tail -n 100 "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
|
||
|
||
exit $EXIT_CODE
|