- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains - Omit embedded publish git dirs and empty placeholders from index Made-with: Cursor
63 lines
2.1 KiB
Bash
63 lines
2.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Schedule cron to check explorer indexer lag and run fix when lag > threshold.
|
|
# Run from project root. Use a host that can reach RPC and Blockscout (and SSH to r630-02 for fix).
|
|
# Usage: bash scripts/maintenance/schedule-explorer-lag-cron.sh [--install|--show|--remove]
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
INSTALL_ROOT="${CRON_PROJECT_ROOT:-$PROJECT_ROOT}"
|
|
LAG_SCRIPT="$INSTALL_ROOT/scripts/maintenance/check-and-fix-explorer-lag.sh"
|
|
LOG_DIR="$INSTALL_ROOT/logs"
|
|
LOG_FILE="$LOG_DIR/explorer-lag-fix.log"
|
|
|
|
# Every 6 hours (0:00, 6:00, 12:00, 18:00)
|
|
CRON_LAG="0 */6 * * * cd $INSTALL_ROOT && bash $LAG_SCRIPT >> $LOG_FILE 2>&1"
|
|
|
|
validate_install_root() {
|
|
if [[ "$INSTALL_ROOT" == /tmp/* ]]; then
|
|
echo "Refusing to install cron from ephemeral path: $INSTALL_ROOT"
|
|
echo "Set CRON_PROJECT_ROOT to a persistent checkout on the host, then rerun."
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "$LAG_SCRIPT" ]]; then
|
|
echo "Lag script not found at: $LAG_SCRIPT"
|
|
echo "Set CRON_PROJECT_ROOT to the host path that contains scripts/maintenance/check-and-fix-explorer-lag.sh."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
case "${1:-}" in
|
|
--install)
|
|
validate_install_root
|
|
mkdir -p "$LOG_DIR"
|
|
{
|
|
crontab -l 2>/dev/null | grep -v "check-and-fix-explorer-lag.sh" || true
|
|
echo "$CRON_LAG"
|
|
} | crontab -
|
|
echo "Installed explorer lag cron (every 6 hours):"
|
|
echo " $CRON_LAG"
|
|
echo "Log: $LOG_FILE"
|
|
;;
|
|
--show)
|
|
validate_install_root
|
|
echo "Explorer lag check-and-fix (every 6 hours):"
|
|
echo " $CRON_LAG"
|
|
echo "Log: $LOG_FILE"
|
|
echo "Threshold: set EXPLORER_INDEXER_LAG_THRESHOLD (default 500) in crontab or env."
|
|
;;
|
|
--remove)
|
|
if crontab -l 2>/dev/null | grep -q "check-and-fix-explorer-lag.sh"; then
|
|
crontab -l 2>/dev/null | grep -v "check-and-fix-explorer-lag.sh" | crontab -
|
|
echo "Removed explorer lag cron."
|
|
else
|
|
echo "No explorer lag cron found in crontab."
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [--install|--show|--remove]"
|
|
exit 0
|
|
;;
|
|
esac
|