-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_web_app.sh
More file actions
executable file
·65 lines (53 loc) · 2.1 KB
/
start_web_app.sh
File metadata and controls
executable file
·65 lines (53 loc) · 2.1 KB
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
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Script to start the web application for Smart Inventory Watchdog Agent
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
echo "🌐 Starting Smart Inventory Watchdog Agent Web Interface"
echo "========================================================"
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "⚠️ Virtual environment not found. Creating one..."
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install --only-binary :all: -r requirements.txt
else
source venv/bin/activate
fi
# Set environment variables
export OPENAI_API_KEY="${OPENAI_API_KEY:-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}"
export ORMCP_URL="${ORMCP_URL:-http://localhost:8082}"
export DEFAULT_THRESHOLD="${DEFAULT_THRESHOLD:-50}"
export ADMIN_EMAILS="${ADMIN_EMAILS:-}"
echo "📋 Configuration:"
echo " OPENAI_API_KEY: ${OPENAI_API_KEY:0:20}..."
echo " ORMCP_URL: $ORMCP_URL"
echo " DEFAULT_THRESHOLD: $DEFAULT_THRESHOLD"
echo ""
# Check if ORMCP server is running
echo "🔍 Checking ORMCP server..."
if ! curl -s "$ORMCP_URL/mcp/" > /dev/null 2>&1; then
echo "⚠️ ORMCP server is not running at $ORMCP_URL"
echo " Please start it first:"
echo " ./start_ormcp.sh"
echo ""
read -p "Press Enter to continue anyway, or Ctrl+C to exit..."
fi
# Check if ecommerce microservice is running
echo "🔍 Checking ecommerce microservice..."
if ! curl -s http://localhost:8081/gilhari/v1/getObjectModelSummary/now > /dev/null; then
echo "⚠️ Ecommerce microservice is not running"
echo " Please start it first:"
echo " ./setup_docker.sh"
echo ""
read -p "Press Enter to continue anyway, or Ctrl+C to exit..."
fi
echo ""
echo "🚀 Starting web server..."
echo " Access the interface at: http://localhost:5001"
echo " (Port 5001 is used to avoid conflicts with macOS AirPlay)"
echo " Press Ctrl+C to stop"
echo ""
# Start Flask app
python3 web_app.py