Files
MatchLiveTv/infra/scripts/cron/scan_ops_logs.sh
Emiliano Frascaro 13390d8a3c Replay fuori da Puma, fix ops cron e firma release Android.
Dopo auth Rails redirect a URL presigned su /media/ (edge → Garage); aumenta
RAILS_MAX_THREADS, corregge ingest log ops via stdin e keystore Play Console.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 22:59:15 +02:00

37 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# Scansiona log Docker recenti e invia pattern sospetti a Rails ops:ingest_logs.
set -euo pipefail
ROOT="${MATCHLIVETV_INFRA:-/opt/matchlivetv/infra}"
SINCE="${OPS_LOG_SCAN_SINCE:-10m}"
ENV_FILE="${ROOT}/.env"
VIDEOS_ROOT="/media/videos/matchlivetv"
TMP="$(mktemp)"
trap 'rm -f "$TMP"' EXIT
if [ -f "$ENV_FILE" ]; then
line="$(grep -E '^MATCHLIVETV_VIDEOS_ROOT=' "$ENV_FILE" 2>/dev/null | tail -1 || true)"
if [ -n "$line" ]; then
VIDEOS_ROOT="${line#MATCHLIVETV_VIDEOS_ROOT=}"
VIDEOS_ROOT="${VIDEOS_ROOT%\"}"
VIDEOS_ROOT="${VIDEOS_ROOT#\"}"
fi
fi
LOG_DIR="${MATCHLIVETV_LOG_DIR:-${VIDEOS_ROOT}/log}"
cd "$ROOT"
docker compose -f docker-compose.prod.yml logs --since "$SINCE" rails sidekiq mediamtx 2>/dev/null > "$TMP" || true
if compgen -G "${LOG_DIR}/youtube_relay_*.log" > /dev/null 2>&1; then
cat "${LOG_DIR}"/youtube_relay_*.log >> "$TMP" 2>/dev/null || true
fi
if [[ ! -s "$TMP" ]]; then
exit 0
fi
# Il file temp è sull'host: passa il contenuto via stdin al container Rails.
"${ROOT}/scripts/cron/run_rails_task.sh" ops:ingest_logs < "$TMP"