File size: 1,556 Bytes
85653bc
 
 
 
 
 
 
6067e63
 
 
 
 
 
 
85653bc
 
6067e63
85653bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6067e63
 
 
85653bc
 
 
 
 
 
6067e63
85653bc
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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