#!/bin/bash # StreamCore - Start all services set -e BASE="/workspace/livestream-platform" echo "[StreamCore] Starting services..." # MediaMTX origin cd "$BASE/mediamtx" if pgrep -f "mediamtx mediamtx.yml" > /dev/null 2>/dev/null; then echo "[StreamCore] MediaMTX already running." else nohup ./mediamtx mediamtx.yml > /tmp/mediamtx.log 2>&1 & sleep 2 echo "[StreamCore] MediaMTX started (RTMP :1935, HLS :8888, API :9997)." fi # Backend API cd "$BASE/backend" if curl -sf http://127.0.0.1:8080/api/health > /dev/null 2>&1; then echo "[StreamCore] Backend already running." else (exec ./venv/bin/python run.py &) /tmp/backend.log & disown sleep 3 echo "[StreamCore] Backend started on :8080." fi # Frontend cd "$BASE/frontend" if curl -sf http://127.0.0.1:5173 > /dev/null 2>&1; then echo "[StreamCore] Frontend already running." else (exec npm run dev &) /tmp/frontend.log & disown sleep 3 echo "[StreamCore] Frontend started on :5173." fi echo "[StreamCore] All services up." echo " Public: http://nbd.rainplay.cn:13001/" echo " Admin: http://nbd.rainplay.cn:13001/admin/login" echo " RTMP: rtmp://nbd.rainplay.cn:13001/live/{key}"