Stiamo aggiornando la piattaforma
++ Il servizio torna online tra pochi secondi. Le dirette RTMP e i replay già pubblicati + non sono interessati da questo aggiornamento. +
+ +Questa pagina si aggiorna automaticamente.
+diff --git a/docs/OPS_MONITORING.md b/docs/OPS_MONITORING.md index 8bd25ec..e4a0a68 100644 --- a/docs/OPS_MONITORING.md +++ b/docs/OPS_MONITORING.md @@ -107,19 +107,27 @@ Watchdog esterno se Rails è completamente giù: ## Workflow rilascio -1. `cd backend && bundle exec rspec` +1. `cd backend && bundle exec rspec` (o equivalente in Docker dev) 2. Ciclo patch/test fino a 0 failure 3. `git commit` → `git push` -4. `bash scripts/deploy/sync_to_server.sh` -5. Rebuild: `docker compose -f docker-compose.prod.yml up -d --build rails sidekiq` -6. Migrate: `docker compose exec -T rails bundle exec rails db:migrate` -7. Cron: `bash scripts/install_production_cron.sh` -8. (Opzionale) `bash scripts/cleanup_obsolete_volumes.sh` — rimuove volumi Docker migrati -9. Smoke test: +4. **`bash scripts/deploy/release_production.sh`** (sync + deploy con pagina di cortesia) + - In alternativa manuale: sync → sul server `bash scripts/deploy/release_production.sh --local` +5. Smoke test: - `curl -sf https://www.matchlivetv.it/up` - `bundle exec rails ops:health_check` (nel container) - Apri `/admin/ops` +### Downtime durante il rilascio + +| Componente | Comportamento | +|------------|---------------| +| `edge` (nginx :3000) | Resta sempre su — NPM non vede mai connection refused | +| Rails in restart | Pagina di cortesia HTML (auto-refresh 15s), non 502 NPM | +| RTMP :1935 / replay | Non toccati dal rilascio web | +| `/up` | Pass-through diretto (monitoraggio ops vede il breve gap) | + +Config edge: [`infra/nginx-edge/`](../infra/nginx-edge/). Script: [`scripts/deploy/release_production.sh`](../scripts/deploy/release_production.sh). + ## Sentry (opzionale) Imposta `SENTRY_DSN` dopo `bundle install`. Gli errori creano anche incidenti ops. diff --git a/docs/infrastructure/SERVER_DEPLOYMENT.md b/docs/infrastructure/SERVER_DEPLOYMENT.md index 729aa16..913d426 100644 --- a/docs/infrastructure/SERVER_DEPLOYMENT.md +++ b/docs/infrastructure/SERVER_DEPLOYMENT.md @@ -63,6 +63,10 @@ Il flusso video **non passa da Rails**: telefono → RTMP :1935 → MediaMTX → ## Nginx Proxy Manager (HTTPS) 1. **Proxy Host** → Forward Hostname: `http://192.168.1.146:3000` (dominio principale `www.matchlivetv.it`, redirect apex `matchlivetv.it` → `www`) + + La porta **3000** è servita dal container **`edge`** (nginx locale), non da Rails direttamente. + Durante i rilasci Rails viene mostrata una **pagina di cortesia** invece del 502 bianco di NPM. + 2. **Websockets:** ON (obbligatorio per `/cable`) 3. **Custom location HLS** (spettatori): - Location: `/hls` @@ -154,17 +158,10 @@ curl -X POST http://192.168.1.146:3000/api/v1/auth/login \ Dalla macchina di sviluppo: ```bash -# Tar + scp (rsync non installato sul server) -tar -C /path/to/MatchLiveTV/src -czf /tmp/matchlivetv-deploy.tar.gz \ - --exclude='./native/android/build' --exclude='./backend/log' --exclude='./.git' . -scp /tmp/matchlivetv-deploy.tar.gz eminux@192.168.1.146:~/ -ssh eminux@192.168.1.146 'tar -xzf ~/matchlivetv-deploy.tar.gz -C ~/matchlivetv' - -# Sul server -cd ~/matchlivetv/infra && docker compose -f docker-compose.prod.yml up -d --build +bash scripts/deploy/release_production.sh ``` -Script: [`scripts/deploy/sync_to_server.sh`](../../scripts/deploy/sync_to_server.sh) (richiede rsync sul server). +Oppure sync manuale: [`scripts/deploy/sync_to_server.sh`](../../scripts/deploy/sync_to_server.sh), poi sul server `bash scripts/deploy/release_production.sh --local`. --- diff --git a/infra/docker-compose.prod.yml b/infra/docker-compose.prod.yml index f2940de..a4c29de 100644 --- a/infra/docker-compose.prod.yml +++ b/infra/docker-compose.prod.yml @@ -52,9 +52,7 @@ services: context: ../backend dockerfile: Dockerfile restart: unless-stopped - command: > - bash -c "bundle exec rails db:prepare && - bundle exec rails server -b 0.0.0.0 -p 3000 -e production" + command: bundle exec rails server -b 0.0.0.0 -p 3000 -e production environment: RAILS_ENV: production DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/matchlivetv @@ -117,8 +115,6 @@ services: OPS_SIDEKIQ_STALE_SECS: ${OPS_SIDEKIQ_STALE_SECS:-300} OPS_LOG_SUBSCRIBER: ${OPS_LOG_SUBSCRIBER:-false} SENTRY_DSN: ${SENTRY_DSN:-} - ports: - - "3000:3000" # Solo LAN — NPM proxy HTTPS depends_on: postgres: condition: service_healthy @@ -139,6 +135,20 @@ services: retries: 10 start_period: 90s + edge: + image: nginx:alpine + restart: unless-stopped + ports: + - "3000:80" # Solo LAN — NPM proxy HTTPS (pagina cortesia se Rails è in restart) + volumes: + - ./nginx-edge/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx-edge/maintenance.html:/usr/share/nginx/maintenance/index.html:ro + healthcheck: + test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:80/edge-health"] + interval: 15s + timeout: 5s + retries: 3 + sidekiq: build: context: ../backend diff --git a/infra/nginx-edge/maintenance.html b/infra/nginx-edge/maintenance.html new file mode 100644 index 0000000..1756502 --- /dev/null +++ b/infra/nginx-edge/maintenance.html @@ -0,0 +1,102 @@ + + +
+ + + + ++ Il servizio torna online tra pochi secondi. Le dirette RTMP e i replay già pubblicati + non sono interessati da questo aggiornamento. +
+ +Questa pagina si aggiorna automaticamente.
+