HLS su edge e monitoraggio ops con latenza p95.
Evita di saturare Puma in diretta, separa i check Rails/pubblico e traccia la latenza /up per alert più affidabili. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -73,6 +73,14 @@ REPLAY_MEDIA_REDIRECT=true
|
||||
# Puma: 5 thread (no secondo worker senza più RAM)
|
||||
RAILS_MAX_THREADS=5
|
||||
|
||||
# Ops — check Rails via edge (critical) + percorso pubblico (warning, ogni 15 min)
|
||||
OPS_HTTP_RAILS_URL=http://edge/up
|
||||
OPS_HTTP_PUBLIC_INTERVAL_SECS=900
|
||||
OPS_UP_LATENCY_WARN_MS=2000
|
||||
OPS_UP_LATENCY_CRIT_MS=5000
|
||||
OPS_UP_LATENCY_SAMPLES=60
|
||||
OPS_UP_LATENCY_MIN_SAMPLES=5
|
||||
|
||||
# Ops monitoring — notifiche push (ntfy self-hosted) e health check
|
||||
# 1) Avvia servizio: docker compose up -d ntfy
|
||||
# 2) NPM: proxy HTTPS → http://192.168.1.146:8090 (es. ntfy.matchlivetv.it, WebSockets ON)
|
||||
|
||||
@@ -108,6 +108,12 @@ services:
|
||||
OPS_NOTIFY_SEVERITIES: ${OPS_NOTIFY_SEVERITIES:-critical,warning}
|
||||
OPS_NOTIFY_COOLDOWN_MINUTES: ${OPS_NOTIFY_COOLDOWN_MINUTES:-30}
|
||||
OPS_HEALTH_INTERVAL_SECS: ${OPS_HEALTH_INTERVAL_SECS:-180}
|
||||
OPS_HTTP_RAILS_URL: ${OPS_HTTP_RAILS_URL:-http://edge/up}
|
||||
OPS_HTTP_PUBLIC_INTERVAL_SECS: ${OPS_HTTP_PUBLIC_INTERVAL_SECS:-900}
|
||||
OPS_UP_LATENCY_WARN_MS: ${OPS_UP_LATENCY_WARN_MS:-2000}
|
||||
OPS_UP_LATENCY_CRIT_MS: ${OPS_UP_LATENCY_CRIT_MS:-5000}
|
||||
OPS_UP_LATENCY_SAMPLES: ${OPS_UP_LATENCY_SAMPLES:-60}
|
||||
OPS_UP_LATENCY_MIN_SAMPLES: ${OPS_UP_LATENCY_MIN_SAMPLES:-5}
|
||||
OPS_HEALTH_TOKEN: ${OPS_HEALTH_TOKEN:-}
|
||||
OPS_DISK_WARN_PERCENT: ${OPS_DISK_WARN_PERCENT:-80}
|
||||
OPS_DISK_CRIT_PERCENT: ${OPS_DISK_CRIT_PERCENT:-90}
|
||||
@@ -198,6 +204,12 @@ services:
|
||||
OPS_NOTIFY_SEVERITIES: ${OPS_NOTIFY_SEVERITIES:-critical,warning}
|
||||
OPS_NOTIFY_COOLDOWN_MINUTES: ${OPS_NOTIFY_COOLDOWN_MINUTES:-30}
|
||||
OPS_HEALTH_INTERVAL_SECS: ${OPS_HEALTH_INTERVAL_SECS:-180}
|
||||
OPS_HTTP_RAILS_URL: ${OPS_HTTP_RAILS_URL:-http://edge/up}
|
||||
OPS_HTTP_PUBLIC_INTERVAL_SECS: ${OPS_HTTP_PUBLIC_INTERVAL_SECS:-900}
|
||||
OPS_UP_LATENCY_WARN_MS: ${OPS_UP_LATENCY_WARN_MS:-2000}
|
||||
OPS_UP_LATENCY_CRIT_MS: ${OPS_UP_LATENCY_CRIT_MS:-5000}
|
||||
OPS_UP_LATENCY_SAMPLES: ${OPS_UP_LATENCY_SAMPLES:-60}
|
||||
OPS_UP_LATENCY_MIN_SAMPLES: ${OPS_UP_LATENCY_MIN_SAMPLES:-5}
|
||||
OPS_HEALTH_TOKEN: ${OPS_HEALTH_TOKEN:-}
|
||||
OPS_DISK_WARN_PERCENT: ${OPS_DISK_WARN_PERCENT:-80}
|
||||
OPS_DISK_CRIT_PERCENT: ${OPS_DISK_CRIT_PERCENT:-90}
|
||||
|
||||
@@ -14,6 +14,11 @@ http {
|
||||
'' close;
|
||||
}
|
||||
|
||||
map $http_cookie $hls_cookie {
|
||||
default $http_cookie;
|
||||
"" "cookieCheck=1";
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
@@ -44,6 +49,26 @@ http {
|
||||
proxy_set_header If-Range $http_if_range;
|
||||
}
|
||||
|
||||
# HLS live/regia: proxy diretto a MediaMTX (non passa da Puma).
|
||||
location /hls/ {
|
||||
limit_except GET HEAD {
|
||||
deny all;
|
||||
}
|
||||
|
||||
rewrite ^/hls/(.*)$ /$1 break;
|
||||
proxy_pass http://mediamtx:8888;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Cookie $hls_cookie;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location = /edge-health {
|
||||
access_log off;
|
||||
add_header Content-Type text/plain;
|
||||
|
||||
Reference in New Issue
Block a user