Aggiunge proxy edge con pagina di cortesia e rilascio a downtime minimo.

NPM punta a nginx locale su :3000 che resta attivo durante il restart Rails; nuovo script release_production.sh esegue migrate, build e deploy in ordine.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-13 09:31:36 +02:00
parent 208664848e
commit 949a0a01fb
6 changed files with 316 additions and 21 deletions

View File

@@ -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.

View File

@@ -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`.
---