#!/bin/bash # Kronos Web UI Docker startup script echo "🚀 Starting Kronos Web UI in Docker..." echo "======================================" # Ensure we run from the script directory (webui) SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" cd "$SCRIPT_DIR" || { echo "❌ Failed to change directory to $SCRIPT_DIR" exit 1 } # Check if we're in the correct directory if [ ! -f "app.py" ]; then echo "❌ app.py not found in $(pwd), please check the working directory" exit 1 fi # Set environment variables export PYTHONPATH=/app export FLASK_APP=webui/app.py export FLASK_ENV=production # Create necessary directories mkdir -p prediction_results mkdir -p model/data # Check if model is available python3 -c " try: from model import Kronos, KronosTokenizer, KronosPredictor print('✅ Kronos model library available') except ImportError as e: print(f'⚠️ Kronos model library not available: {e}') print(' Will use simulated data for demonstration') " # Start the Flask application PORT="${PORT:-7860}" echo "🌐 Starting Flask server on port ${PORT}..." echo "Access URL: http://localhost:${PORT}" echo "Press Ctrl+C to stop server" echo "" # Use gunicorn for production if available, otherwise use Flask dev server if command -v gunicorn &> /dev/null; then echo "Using Gunicorn for production..." exec gunicorn --bind 0.0.0.0:${PORT} --workers 2 --timeout 120 --access-logfile - --error-logfile - app:app else echo "Using Flask development server..." exec python3 app.py fi