-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_app.sh
More file actions
executable file
·62 lines (53 loc) · 1.66 KB
/
Copy pathstart_app.sh
File metadata and controls
executable file
·62 lines (53 loc) · 1.66 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
#!/bin/bash
# Omega Portfolio Engine Startup Script
echo "Starting Omega Portfolio Engine web application..."
echo "API will be available at: http://localhost:8000"
echo "Web UI will be available at: http://localhost:8501"
echo "Press Ctrl+C to stop both services"
echo ""
# Activate virtual environment
source venv/bin/activate
# Check if API is already running
if lsof -i :8000 > /dev/null 2>&1; then
echo "API server is already running on port 8000"
API_PID=$(lsof -ti :8000)
echo "Using existing API server (PID: $API_PID)"
else
# Start API server in background
echo "Starting API server in background..."
python -m api.main &
API_PID=$!
# Wait for API to start
echo "Waiting for API to start..."
sleep 5
# Check if API is running
if ps -p $API_PID > /dev/null; then
echo "API server started successfully (PID: $API_PID)"
else
echo "Failed to start API server"
exit 1
fi
fi
# Start Streamlit UI
echo "Starting web UI..."
streamlit run app/ui.py --server.port 8501 --server.address 0.0.0.0
# Cleanup function
cleanup() {
echo "Shutting down services..."
# Only kill API if we started it ourselves
if [ "$API_PID" != "" ] && ps -p $API_PID > /dev/null 2>&1; then
# Check if this is a process we started (not an existing one)
if lsof -i :8000 > /dev/null 2>&1; then
echo "Stopping API server..."
kill $API_PID 2>/dev/null
else
echo "API server was already running, leaving it running"
fi
fi
pkill -f streamlit 2>/dev/null
exit 0
}
# Set up signal handlers
trap cleanup SIGINT SIGTERM
# Wait for user to stop
wait