feat: Add editor enhancements - export video, audio preview, publish panel, configurable ports
This commit is contained in:
160
dev.sh
Executable file
160
dev.sh
Executable file
@@ -0,0 +1,160 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Pixelle-Video Development Environment Startup Script
|
||||
# =============================================================================
|
||||
#
|
||||
# This script starts all services for development:
|
||||
# - FastAPI Backend (port 8000)
|
||||
# - Next.js Editor (port 3000)
|
||||
# - Streamlit Web UI (port 8501)
|
||||
#
|
||||
# Usage:
|
||||
# ./dev.sh # Start all services
|
||||
# ./dev.sh api # Start only API
|
||||
# ./dev.sh editor # Start only Editor
|
||||
# ./dev.sh web # Start only Streamlit
|
||||
# ./dev.sh stop # Stop all background services
|
||||
#
|
||||
# Environment Variables:
|
||||
# API_PORT=8000 # Override API port
|
||||
# EDITOR_PORT=3000 # Override Editor port
|
||||
# WEB_PORT=8501 # Override Streamlit port
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Default ports (can be overridden via environment variables)
|
||||
API_PORT=${API_PORT:-8000}
|
||||
EDITOR_PORT=${EDITOR_PORT:-3000}
|
||||
WEB_PORT=${WEB_PORT:-8501}
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Project root directory
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# PID files for tracking background processes
|
||||
PID_DIR="$PROJECT_ROOT/.pids"
|
||||
mkdir -p "$PID_DIR"
|
||||
|
||||
print_banner() {
|
||||
echo ""
|
||||
echo -e "${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║ Pixelle-Video Development Environment ║${NC}"
|
||||
echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
start_api() {
|
||||
echo -e "${GREEN}🚀 Starting FastAPI Backend...${NC}"
|
||||
uv run python api/app.py --port $API_PORT --reload &
|
||||
echo $! > "$PID_DIR/api.pid"
|
||||
echo -e " ${GREEN}✓${NC} API running at: ${YELLOW}http://localhost:$API_PORT${NC}"
|
||||
echo -e " ${GREEN}✓${NC} API Docs at: ${YELLOW}http://localhost:$API_PORT/docs${NC}"
|
||||
}
|
||||
|
||||
start_editor() {
|
||||
echo -e "${GREEN}🎬 Starting Next.js Editor...${NC}"
|
||||
cd "$PROJECT_ROOT/frontend"
|
||||
PORT=$EDITOR_PORT npm run dev &
|
||||
echo $! > "$PID_DIR/editor.pid"
|
||||
cd "$PROJECT_ROOT"
|
||||
echo -e " ${GREEN}✓${NC} Editor running at: ${YELLOW}http://localhost:$EDITOR_PORT${NC}"
|
||||
}
|
||||
|
||||
start_web() {
|
||||
echo -e "${GREEN}🌐 Starting Streamlit Web UI...${NC}"
|
||||
uv run streamlit run web/app.py --server.port $WEB_PORT &
|
||||
echo $! > "$PID_DIR/web.pid"
|
||||
echo -e " ${GREEN}✓${NC} Web UI running at: ${YELLOW}http://localhost:$WEB_PORT${NC}"
|
||||
}
|
||||
|
||||
stop_all() {
|
||||
echo -e "${YELLOW}Stopping all services...${NC}"
|
||||
|
||||
for pid_file in "$PID_DIR"/*.pid; do
|
||||
if [ -f "$pid_file" ]; then
|
||||
pid=$(cat "$pid_file")
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
echo -e " ${GREEN}✓${NC} Stopped process $pid"
|
||||
fi
|
||||
rm -f "$pid_file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Also kill any remaining processes on our ports
|
||||
lsof -ti:$API_PORT | xargs kill -9 2>/dev/null || true
|
||||
lsof -ti:$EDITOR_PORT | xargs kill -9 2>/dev/null || true
|
||||
lsof -ti:$WEB_PORT | xargs kill -9 2>/dev/null || true
|
||||
|
||||
echo -e "${GREEN}All services stopped.${NC}"
|
||||
}
|
||||
|
||||
show_status() {
|
||||
echo ""
|
||||
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${GREEN}All services started successfully!${NC}"
|
||||
echo ""
|
||||
echo -e " ${YELLOW}FastAPI Backend${NC}: http://localhost:$API_PORT"
|
||||
echo -e " ${YELLOW}API Documentation${NC}: http://localhost:$API_PORT/docs"
|
||||
echo -e " ${YELLOW}Next.js Editor${NC}: http://localhost:$EDITOR_PORT"
|
||||
echo -e " ${YELLOW}Streamlit Web UI${NC}: http://localhost:$WEB_PORT"
|
||||
echo ""
|
||||
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo -e "Press ${RED}Ctrl+C${NC} to stop all services"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Main logic
|
||||
case "${1:-all}" in
|
||||
api)
|
||||
print_banner
|
||||
start_api
|
||||
wait
|
||||
;;
|
||||
editor)
|
||||
print_banner
|
||||
start_editor
|
||||
wait
|
||||
;;
|
||||
web)
|
||||
print_banner
|
||||
start_web
|
||||
wait
|
||||
;;
|
||||
stop)
|
||||
stop_all
|
||||
;;
|
||||
all|*)
|
||||
print_banner
|
||||
|
||||
# Check if frontend dependencies are installed
|
||||
if [ ! -d "$PROJECT_ROOT/frontend/node_modules" ]; then
|
||||
echo -e "${YELLOW}📦 Installing frontend dependencies...${NC}"
|
||||
cd "$PROJECT_ROOT/frontend"
|
||||
npm install
|
||||
cd "$PROJECT_ROOT"
|
||||
fi
|
||||
|
||||
start_api
|
||||
sleep 2
|
||||
start_editor
|
||||
sleep 2
|
||||
start_web
|
||||
|
||||
show_status
|
||||
|
||||
# Wait for Ctrl+C
|
||||
trap stop_all EXIT
|
||||
wait
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user