**Motivations:** - Consigner l'état actuel du dépôt (cron, service-login-verify, website-skeleton, userwallet, docs). - Centraliser les modifications en attente. **Root causes:** - N/A (commit groupé). **Correctifs:** - N/A. **Evolutions:** - Cron quotidien restart services : script local sans SSH, systemd (bitcoin-signet, bitcoin, APIs, dashboard, userwallet, website-skeleton) + Docker (mempool, bitcoin-signet-instance). - Feature cron-restart-services-local : documentation et règle scripts locaux / pas d'SSH. - service-login-verify : module vérification login (buildAllowedPubkeys, verifyLoginProof, nonceCache). - website-skeleton : app iframe UserWallet, config, systemd unit. - userwallet : collectSignatures, relay. - docs : DOMAINS_AND_PORTS, README, WEBSITE_SKELETON ; features userwallet-contrat-login, timeouts-backoff, service-login-verify. **Pages affectées:** - data/restart-services-cron.sh, data/restart-services.log, data/sync-utxos.log - features/cron-restart-services-local.md, features/service-login-verify.md, features/userwallet-contrat-login-reste-a-faire.md, features/userwallet-timeouts-backoff.md - docs/DOMAINS_AND_PORTS.md, docs/README.md, docs/WEBSITE_SKELETON.md - configure-nginx-proxy.sh - service-login-verify/ (src, dist, node_modules) - userwallet/src/utils/collectSignatures.ts, userwallet/src/utils/relay.ts - website-skeleton/
98 lines
2.8 KiB
Bash
Executable File
98 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Daily restart of project systemd services (local only).
|
|
# Run via cron. Requires passwordless sudo for systemctl restart.
|
|
# Log: data/restart-services.log
|
|
#
|
|
# Local only: no SSH, no remote commands. Manages systemd units and
|
|
# local Docker (mempool stack, bitcoind container) on the current machine.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
LOG_FILE="$SCRIPT_DIR/restart-services.log"
|
|
MEMPOOL_COMPOSE="${PROJECT_DIR}/mempool/docker-compose.signet.yml"
|
|
BITCOIND_CONTAINER="bitcoin-signet-instance"
|
|
|
|
SERVICES=(
|
|
bitcoin-signet
|
|
bitcoin
|
|
anchorage-api
|
|
api-relay
|
|
clamav-api
|
|
faucet-api
|
|
filigrane-api
|
|
signet-dashboard
|
|
userwallet
|
|
website-skeleton
|
|
)
|
|
|
|
log() { echo "$(date -Iseconds) $*" | tee -a "$LOG_FILE"; }
|
|
|
|
cd "$PROJECT_DIR" || exit 1
|
|
|
|
log "=== Restart services cron (local only, no SSH) ==="
|
|
|
|
# 1. Verify enabled (warn if not)
|
|
for u in "${SERVICES[@]}"; do
|
|
if ! systemctl is-enabled "$u" &>/dev/null; then
|
|
log "WARN: $u is not enabled (will not start at boot)"
|
|
fi
|
|
done
|
|
|
|
# 2. Restart active units; track attempted
|
|
restarted=()
|
|
for u in "${SERVICES[@]}"; do
|
|
if ! systemctl is-active --quiet "$u" 2>/dev/null; then
|
|
log "SKIP: $u not active (not installed or not running on this machine)"
|
|
continue
|
|
fi
|
|
log "Restarting $u..."
|
|
if sudo systemctl restart "$u"; then
|
|
log " $u OK"
|
|
restarted+=("$u")
|
|
else
|
|
log " $u FAILED"
|
|
restarted+=("$u")
|
|
fi
|
|
done
|
|
|
|
# 3. Verify active for restarted units
|
|
for u in "${restarted[@]}"; do
|
|
if ! systemctl is-active --quiet "$u" 2>/dev/null; then
|
|
log "WARN: $u not active after restart"
|
|
fi
|
|
done
|
|
|
|
# 4. Docker: mempool stack (local only)
|
|
if [ -f "$MEMPOOL_COMPOSE" ] && command -v docker &>/dev/null; then
|
|
log "Restarting mempool (docker)..."
|
|
mem_ok=1
|
|
(cd "${PROJECT_DIR}/mempool" && docker compose -f docker-compose.signet.yml restart &>/dev/null) && mem_ok=0
|
|
[ "$mem_ok" -ne 0 ] && (cd "${PROJECT_DIR}/mempool" && docker-compose -f docker-compose.signet.yml restart &>/dev/null) && mem_ok=0
|
|
if [ "$mem_ok" -eq 0 ]; then
|
|
log " mempool OK"
|
|
else
|
|
log " mempool FAILED"
|
|
fi
|
|
else
|
|
if [ ! -f "$MEMPOOL_COMPOSE" ]; then
|
|
log "SKIP: mempool compose not found (not deployed on this machine)"
|
|
else
|
|
log "SKIP: mempool requires docker (not available)"
|
|
fi
|
|
fi
|
|
|
|
# 5. Docker: bitcoind container (local only)
|
|
if docker ps -a -q -f "name=^${BITCOIND_CONTAINER}$" 2>/dev/null | grep -q .; then
|
|
log "Restarting $BITCOIND_CONTAINER..."
|
|
if docker restart "$BITCOIND_CONTAINER" &>/dev/null; then
|
|
log " $BITCOIND_CONTAINER OK"
|
|
else
|
|
log " $BITCOIND_CONTAINER FAILED"
|
|
fi
|
|
else
|
|
log "SKIP: $BITCOIND_CONTAINER container not found (bitcoind may run as systemd)"
|
|
fi
|
|
|
|
log "=== Done ==="
|
|
tail -n 100 "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
|