Files
vna_system/vna_system/scripts/start.sh
2025-09-23 18:42:55 +03:00

92 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
#
# VNA System Startup Script
#
# This script starts the VNA System API server with proper environment setup
#
set -e # Exit on any error
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "$PROJECT_ROOT/vna_system/api/main.py" ]; then
log_error "VNA System main.py not found. Please run this script from the project directory."
exit 1
fi
# Change to project root
cd "$PROJECT_ROOT"
log_info "Starting VNA System from: $PROJECT_ROOT"
# Check Python version
if ! command -v python3 &> /dev/null; then
log_error "Python 3 is not installed or not in PATH"
exit 1
fi
PYTHON_VERSION=$(python3 --version 2>&1 | cut -d' ' -f2)
log_info "Using Python version: $PYTHON_VERSION"
# Check if virtual environment exists
if [ -d "venv" ] || [ -d ".venv" ]; then
if [ -d "venv" ]; then
VENV_PATH="venv"
else
VENV_PATH=".venv"
fi
log_info "Found virtual environment at: $VENV_PATH"
log_info "Activating virtual environment..."
# Activate virtual environment
source "$VENV_PATH/bin/activate"
log_success "Virtual environment activated"
else
log_warning "No virtual environment found. Using system Python."
log_warning "Consider creating a virtual environment: python3 -m venv venv"
fi
# Check configuration files
if [ ! -f "vna_system/api/api_config.json" ]; then
log_warning "API config not found. Using defaults."
fi
if [ ! -f "vna_system/core/processing/config.json" ]; then
log_warning "Processing config not found. Some processors may not work."
fi
# Start the server
log_info "Starting VNA System API server..."
log_info "Press Ctrl+C to stop the server"
echo
# Run the main application
exec python3 -m vna_system.api.main