1
0
mirror of git://f0xx.org/ac/ac-deploy synced 2026-07-29 04:19:00 +03:00

feat(cluster0): add Janus SFU deploy script and graph gzip smoke test

deploy-janus-sfu.sh installs Janus on cast02, writes signaling config, and templates CAST02_IP into nginx; populate gains --phase sfu.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyeu
2026-07-10 22:12:02 +02:00
parent dfe701f2de
commit a411dc5405
5 changed files with 128 additions and 5 deletions

View File

@@ -76,7 +76,24 @@ echo
echo "…" echo "…"
if [[ "${upload_code}" != "200" ]]; then if [[ "${upload_code}" != "200" ]]; then
echo "FAIL: upload expected 200" >&2 echo "FAIL: plain upload expected 200" >&2
exit 1
fi
sid_gzip="smoke-graph-gzip-$(date +%s)"
payload_gzip="${payload/${sid}/${sid_gzip}}"
echo "POST ${UPLOAD_URL} (gzip, device-style)"
gzip_upload_code="$(curl -sS -o /tmp/graph_upload_gzip_resp.json -w '%{http_code}' \
-H 'Content-Type: application/json' \
-H 'Content-Encoding: gzip' \
--data-binary @<(printf '%s' "${payload_gzip}" | gzip -c) \
"${UPLOAD_URL}")"
echo "gzip upload HTTP ${gzip_upload_code}"
cat /tmp/graph_upload_gzip_resp.json
echo
if [[ "${gzip_upload_code}" != "200" ]]; then
echo "FAIL: gzip upload expected 200" >&2
exit 1 exit 1
fi fi
if [[ "${graphs_code}" != "200" ]]; then if [[ "${graphs_code}" != "200" ]]; then

View File

@@ -290,7 +290,7 @@ server {
# WebSocket → Janus on cast02 # WebSocket → Janus on cast02
location /app/androidcast_project/sfu/ws { location /app/androidcast_project/sfu/ws {
proxy_pass http://10.7.16.237:8188/; proxy_pass http://@CAST02_IP@:8188/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade; proxy_set_header Connection $connection_upgrade;

View File

@@ -3,7 +3,7 @@
# Usage: # Usage:
# sudo sh populate_lab_setup.sh # full setup on this node # sudo sh populate_lab_setup.sh # full setup on this node
# sudo sh populate_lab_setup.sh --coordinator # from jump host: all nodes in order # sudo sh populate_lab_setup.sh --coordinator # from jump host: all nodes in order
# sudo sh populate_lab_setup.sh --phase baseline|db|app|all # sudo sh populate_lab_setup.sh --phase baseline|db|app|sfu|all
set -eu set -eu
ROOT="$(cd "$(dirname "$0")" && pwd)" ROOT="$(cd "$(dirname "$0")" && pwd)"
@@ -20,7 +20,7 @@ while [ $# -gt 0 ]; do
--coordinator) COORDINATOR=1; shift ;; --coordinator) COORDINATOR=1; shift ;;
--phase) PHASE="${2:-all}"; shift 2 ;; --phase) PHASE="${2:-all}"; shift 2 ;;
--help|-h) --help|-h)
echo "Usage: sudo sh populate_lab_setup.sh [--coordinator] [--phase baseline|db|app|all]" echo "Usage: sudo sh populate_lab_setup.sh [--coordinator] [--phase baseline|db|app|sfu|all]"
exit 0 exit 0
;; ;;
*) die "unknown arg: $1" ;; *) die "unknown arg: $1" ;;
@@ -61,6 +61,18 @@ run_phase_db() {
die "unknown host for db phase: $(host_short)" die "unknown host for db phase: $(host_short)"
} }
run_phase_sfu() {
JOURNAL_PHASE=sfu
journal_start phase_sfu "$(host_short)"
log "phase sfu on $(host_short)"
if is_replica_node; then
wait_for_primary_db
fi
run_script "$ROOT/scripts/deploy-ac-workspace.sh"
run_script "$ROOT/scripts/deploy-janus-sfu.sh"
journal_ok phase_sfu
}
run_phase_app() { run_phase_app() {
JOURNAL_PHASE=app JOURNAL_PHASE=app
journal_start phase_app "$(host_short)" journal_start phase_app "$(host_short)"
@@ -109,6 +121,7 @@ run_local() {
baseline) run_phase_baseline ;; baseline) run_phase_baseline ;;
db) run_phase_baseline; run_phase_db ;; db) run_phase_baseline; run_phase_db ;;
app) run_phase_app ;; app) run_phase_app ;;
sfu) run_phase_sfu ;;
all) all)
run_phase_baseline || exit 1 run_phase_baseline || exit 1
run_phase_db || exit 1 run_phase_db || exit 1
@@ -142,6 +155,12 @@ run_coordinator() {
done done
wait wait
ssh_node "$CAST02_HOST" "sudo sh ${SHARED_MOUNT}/cluster/populate_lab_setup.sh --phase sfu"
for H in $CAST01_HOST $CAST03_HOST; do
ssh_node "$H" "sudo sh ${SHARED_MOUNT}/cluster/populate_lab_setup.sh --phase sfu" &
done
wait
sh "$ROOT/verify_lab_setup.sh" --cluster sh "$ROOT/verify_lab_setup.sh" --cluster
journal_ok populate_coordinator journal_ok populate_coordinator
log "populate_coordinator_ok ${CLUSTER_NAME}" log "populate_coordinator_ok ${CLUSTER_NAME}"

View File

@@ -17,7 +17,11 @@ if [ -f "$GIT_NGINX" ] && [ "$(realpath "$GIT_NGINX" 2>/dev/null)" != "$(realpat
fi fi
fi fi
[ -s "$CONF_DST" ] || die "missing or empty nginx template at $CONF_DST" [ -s "$CONF_DST" ] || die "missing or empty nginx template at $CONF_DST"
install -D -m 644 "$CONF_DST" /etc/nginx/http.d/androidcast.conf load_cluster_env 2>/dev/null || true
CAST02_IP="${CAST02_IP:-10.7.16.237}"
sed "s/@CAST02_IP@/${CAST02_IP}/g" "$CONF_DST" > /tmp/androidcast.conf.$$
install -D -m 644 /tmp/androidcast.conf.$$ /etc/nginx/http.d/androidcast.conf
rm -f /tmp/androidcast.conf.$$
rm -f /etc/nginx/http.d/default.conf /etc/nginx/http.d/cluster.conf 2>/dev/null || true rm -f /etc/nginx/http.d/default.conf /etc/nginx/http.d/cluster.conf 2>/dev/null || true
nginx -t nginx -t
rc-service nginx reload rc-service nginx reload

View File

@@ -0,0 +1,83 @@
#!/bin/sh
# Janus SFU on cast02 + ac-ms-sfu-signaling config on all app nodes.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# shellcheck source=/dev/null
. "$ROOT/scripts/lib/common.sh"
load_cluster_env
WS="${AC_WORKSPACE_ROOT:-/var/www/ac/workspace}"
AC_REPO="${AC_MONOREPO_ROOT:-/mnt/repos/ac}"
SFU_WS="${WS}/ac-ms-sfu-signaling"
if [ ! -d "$SFU_WS" ] && [ -d "${AC_REPO}/ac-ms-sfu-signaling" ]; then
mkdir -p "$(dirname "$SFU_WS")"
rsync -a --delete "${AC_REPO}/ac-ms-sfu-signaling/" "$SFU_WS/" 2>/dev/null \
|| cp -a "${AC_REPO}/ac-ms-sfu-signaling/." "$SFU_WS/"
fi
[ -d "$SFU_WS" ] || die "missing ac-ms-sfu-signaling (run deploy-ac-workspace.sh first)"
PUBLIC_ORIGIN="${LAB_PUBLIC_ORIGIN:-https://apps.f0xx.org}"
JANUS_HTTP="http://${CAST02_IP}:8088/janus"
JANUS_WS="ws://${CAST02_IP}:8188"
install_janus_on_cast02() {
[ "$(host_short)" = "$CAST02_HOST" ] || return 0
log "cast02: install/configure Janus SFU"
if ! command -v janus >/dev/null 2>&1; then
apk add --no-cache janus-gateway janus-gateway-openrc
fi
for _pair in \
"janus.jcfg janus.jcfg.sample" \
"janus.transport.http.jcfg janus.transport.http.jcfg.sample" \
"janus.transport.websockets.jcfg janus.transport.websockets.jcfg.sample" \
"janus.plugin.videoroom.jcfg janus.plugin.videoroom.jcfg.sample"
do
_dst="${_pair%% *}"
_src="${_pair#* }"
[ -f "/etc/janus/${_dst}" ] || cp "/etc/janus/${_src}" "/etc/janus/${_dst}"
done
rc-update add janus-gateway default 2>/dev/null || true
rc-service janus-gateway restart 2>/dev/null || rc-service janus-gateway start 2>/dev/null || true
if curl -sf "http://127.0.0.1:8088/janus/info" >/dev/null 2>&1; then
log "cast02: Janus HTTP API OK"
else
log "WARN cast02: Janus health check failed (may still be starting)"
fi
}
write_sfu_config() {
DB_PASS="$(read_cred mariadb_app password 2>/dev/null || echo 'CHANGE_ME')"
mkdir -p "${SFU_WS}/config"
cat > "${SFU_WS}/config/config.php" <<PHPEOF
<?php
return [
'janus_url' => '${JANUS_HTTP}',
'janus_ws_url' => '${JANUS_WS}',
'signaling_url' => '${PUBLIC_ORIGIN}/app/androidcast_project/sfu/ws',
'db_dsn' => 'mysql:host=${PRIMARY_DB_HOST};dbname=androidcast_crashes;charset=utf8mb4',
'db_user' => 'androidcast',
'db_pass' => '${DB_PASS}',
];
PHPEOF
chown -R nginx:nginx "$SFU_WS" 2>/dev/null || true
log "sfu signaling config → ${SFU_WS}/config/config.php"
}
apply_sfu_schema() {
is_primary_node || return 0
log "primary: apply SFU schema migrations"
run_script "$ROOT/scripts/load-schemas.sh" || log "WARN load-schemas returned non-zero (may already be applied)"
}
install_janus_on_cast02
write_sfu_config
apply_sfu_schema
run_script "$ROOT/scripts/configure-nginx.sh"
rc-service php-fpm83 restart 2>/dev/null || true
if [ "$(host_short)" = "$CAST02_HOST" ]; then
curl -sf "http://127.0.0.1:8088/janus/info" | head -c 120 || true
echo
fi
log "deploy-janus-sfu_ok $(host_short)"