-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
199 lines (174 loc) ยท 5.26 KB
/
Copy pathstart.sh
File metadata and controls
199 lines (174 loc) ยท 5.26 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash
# Codenames Game Startup Script
set -e
echo "๐ฎ Starting Codenames Robotics Game..."
# Check if .env file exists
if [ ! -f .env ]; then
echo "โ ๏ธ No .env file found. Creating from template..."
if [ -f .env.template ]; then
cp .env.template .env
echo "โ
Created .env file from template"
echo "๐ Please edit .env with your API keys before running again"
else
echo "โ No .env.template found. Please create .env file manually"
exit 1
fi
fi
# Check Docker is running
if ! docker info > /dev/null 2>&1; then
echo "โ Docker is not running. Please start Docker first."
exit 1
fi
# Function to show usage
show_usage() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --build Force rebuild of containers"
echo " --isaac Include Isaac Sim bridge"
echo " --logs Show container logs"
echo " --status Show container status"
echo " --stop Stop all containers"
echo " --clean Stop and remove all containers"
echo " --test Run basic connectivity tests"
echo " --help Show this help message"
}
# Function to check container health
check_health() {
echo "๐ Checking container health..."
# Check if containers are running
RUNNING=$(docker-compose ps --services --filter "status=running" | wc -l)
TOTAL=$(docker-compose ps --services | wc -l)
echo "๐ Containers running: $RUNNING/$TOTAL"
if [ "$RUNNING" -eq "$TOTAL" ]; then
echo "โ
All containers are healthy"
# Test ROS2 connectivity
echo "๐ Testing ROS2 connectivity..."
timeout 10 docker-compose exec -T orchestrator ros2 node list > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "โ
ROS2 nodes are communicating"
else
echo "โ ๏ธ ROS2 connectivity test failed"
fi
# Test web interface
echo "๐ Testing web interface..."
if curl -s http://localhost:8080 > /dev/null 2>&1; then
echo "โ
Web interface is accessible"
else
echo "โ ๏ธ Web interface test failed"
fi
else
echo "โ Some containers are not running"
docker-compose ps
fi
}
# Function to run tests
run_tests() {
echo "๐งช Running system tests..."
# Wait for services to be ready
echo "โณ Waiting for services to start..."
sleep 10
# Test API endpoints
echo "๐ Testing API endpoints..."
if curl -s http://localhost:8080/api/status | jq . > /dev/null 2>&1; then
echo "โ
API endpoints responding"
else
echo "โ API test failed"
fi
# Test ROS2 topics
echo "๐ Testing ROS2 topics..."
TOPICS=$(timeout 5 docker-compose exec -T orchestrator ros2 topic list 2>/dev/null | grep "/game/" | wc -l)
if [ "$TOPICS" -gt 0 ]; then
echo "โ
ROS2 topics active ($TOPICS found)"
else
echo "โ No game topics found"
fi
check_health
}
# Parse command line arguments
BUILD_FLAG=""
ISAAC_PROFILE=""
COMMAND="up -d"
while [[ $# -gt 0 ]]; do
case $1 in
--build)
BUILD_FLAG="--build"
shift
;;
--isaac)
ISAAC_PROFILE="--profile isaac"
echo "๐ค Including Isaac Sim bridge..."
shift
;;
--logs)
COMMAND="logs -f"
shift
;;
--status)
docker-compose ps
check_health
exit 0
;;
--test)
run_tests
exit 0
;;
--stop)
echo "๐ Stopping Codenames containers..."
docker-compose down
exit 0
;;
--clean)
echo "๐งน Cleaning up containers and volumes..."
docker-compose down -v --remove-orphans
docker system prune -f
exit 0
;;
--help)
show_usage
exit 0
;;
*)
echo "Unknown option: $1"
show_usage
exit 1
;;
esac
done
# Create necessary directories
echo "๐ Creating necessary directories..."
mkdir -p models/bert_similarity
mkdir -p frontend/templates
mkdir -p frontend/static/{css,js,images}
# Build and start containers
echo "๐ Starting containers..."
docker-compose $ISAAC_PROFILE $COMMAND $BUILD_FLAG
if [ "$COMMAND" = "up -d" ]; then
echo ""
echo "โณ Waiting for services to start..."
sleep 5
# Check if services started successfully
check_health
echo ""
echo "โ
Codenames Game is starting!"
echo ""
echo "๐ Frontend: http://localhost:8080"
echo "โ๏ธ Admin Panel: http://localhost:8080/admin"
echo "๐ก API Status: http://localhost:8080/api/status"
echo ""
echo "๐ Check container status:"
echo " ./start.sh --status"
echo ""
echo "๐ View logs:"
echo " ./start.sh --logs"
echo " docker-compose logs -f [service_name]"
echo ""
echo "๐งช Run tests:"
echo " ./start.sh --test"
echo ""
echo "๐ Stop all containers:"
echo " ./start.sh --stop"
echo ""
echo "๐งน Clean everything:"
echo " ./start.sh --clean"
fi