-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
115 lines (102 loc) · 3.09 KB
/
Copy pathstart.sh
File metadata and controls
115 lines (102 loc) · 3.09 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
# Start script for Mini Agent Platform
# This script starts the database, runs migrations, and starts the API server
# Usage: ./start.sh [--skip-db] [--skip-migrations] [--skip-tests]
set -e
SKIP_DB=false
SKIP_MIGRATIONS=false
SKIP_TESTS=true
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--skip-db)
SKIP_DB=true
shift
;;
--skip-migrations)
SKIP_MIGRATIONS=true
shift
;;
--skip-tests)
SKIP_TESTS=true
shift
;;
--run-tests)
SKIP_TESTS=false
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: ./start.sh [--skip-db] [--skip-migrations] [--run-tests]"
exit 1
;;
esac
done
echo "=========================================="
echo "Mini Agent Platform - Starting"
echo "=========================================="
echo ""
# Activate virtual environment
if [ ! -d ".venv" ]; then
echo "ERROR: Virtual environment not found!"
echo " Please run ./setup.sh first"
exit 1
fi
echo "Activating virtual environment..."
source .venv/bin/activate 2>/dev/null || . .venv/Scripts/activate 2>/dev/null
# Check if database is running
if [ "$SKIP_DB" = false ]; then
echo ""
echo "Checking database connection..."
# Check if MySQL container is running (Docker)
if docker ps --format '{{.Names}}' | grep -q "agent_platform_mysql\|mysql-agent-platform"; then
echo " MySQL Docker container is running"
else
# Check if MySQL is accessible on localhost
if command -v mysql &> /dev/null; then
if mysql -h localhost -P 3306 -u root -ppassword -e "SELECT 1" &> /dev/null; then
echo " MySQL is accessible"
else
echo " WARNING: MySQL is not accessible"
echo " Starting MySQL with Docker..."
if [ -f "./run-db.sh" ]; then
./run-db.sh
echo " Waiting for MySQL to be ready..."
sleep 5
else
echo " ERROR: run-db.sh not found. Please start MySQL manually."
exit 1
fi
fi
else
echo " WARNING: MySQL client not found. Assuming MySQL is running."
fi
fi
fi
# Run migrations
if [ "$SKIP_MIGRATIONS" = false ]; then
echo ""
echo "Running database migrations..."
alembic upgrade head
echo " Migrations completed"
fi
# Run tests (optional)
if [ "$SKIP_TESTS" = false ]; then
echo ""
echo "Running tests..."
pytest tests/ -v --tb=short
if [ $? -eq 0 ]; then
echo " All tests passed"
else
echo " WARNING: Some tests failed, but continuing..."
fi
fi
# Start the application
echo ""
echo "Starting FastAPI server..."
echo " API will be available at: http://localhost:8000"
echo " API docs: http://localhost:8000/docs"
echo ""
echo " Press Ctrl+C to stop the server"
echo ""
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000