-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
240 lines (225 loc) · 9.9 KB
/
Copy pathMakefile
File metadata and controls
240 lines (225 loc) · 9.9 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# RoleRadar Makefile
# English Makefile for RoleRadar project
.DEFAULT_GOAL := run
.PHONY: help install run run-cpu run-gpu run-backend run-frontend stop stop-backend stop-frontend clean logs status
# Show help message
help:
@echo "RoleRadar - Available commands:"
@echo " install - Interactive installation with CPU/GPU selection"
@echo " run - Start all services (interactive mode selection if no active config)"
@echo " run-cpu - Start all services with CPU mode"
@echo " run-gpu - Start all services with GPU mode"
@echo " run-backend - Start only backend services (superlinked + qdrant)"
@echo " run-frontend - Start only frontend service"
@echo " stop - Stop all services"
@echo " stop-backend - Stop only backend services (superlinked + qdrant)"
@echo " stop-frontend - Stop only frontend service"
@echo " clean - Stop services and remove containers/volumes"
@echo " logs - Show logs from all services"
@echo " status - Check service status"
@echo " help - Show this help message"
# Install and setup the system with data loading
install:
@echo "🚀 Starting RoleRadar installation..."
@echo "🖥️ Please select processing mode:"
@echo " 1) CPU mode (recommended for most systems)"
@echo " 2) GPU mode (requires NVIDIA GPU and drivers)"
@printf "Enter your choice (1 or 2): "; \
read choice; \
if [ "$$choice" = "2" ]; then \
echo "🚀 Setting up GPU mode..."; \
COMPOSE_FILE="docker-compose.gpu.yml"; \
else \
echo "🚀 Setting up CPU mode..."; \
COMPOSE_FILE="docker-compose.cpu.yml"; \
fi; \
docker compose -f $$COMPOSE_FILE up -d --build --force-recreate --no-deps
@echo "⏳ Waiting 30 seconds for services to start..."
@sleep 30
@echo "🔍 Checking if Qdrant collection exists..."
@until curl -s http://localhost:6333/collections/default/exists 2>/dev/null | jq -e '.result.exists == true' >/dev/null 2>&1; do \
echo "Waiting for collection to be available..."; \
sleep 5; \
done
@echo "✅ Collection exists, starting data loading..."
@echo "📊 Getting data loader configuration..."
@RETRY_COUNT=0; \
while [ $$RETRY_COUNT -lt 10 ]; do \
DATA_LOADER_RESPONSE=$$(curl -s http://localhost:8080/data-loader/ 2>/dev/null); \
if [ -n "$$DATA_LOADER_RESPONSE" ] && echo "$$DATA_LOADER_RESPONSE" | jq -e '.result' >/dev/null 2>&1; then \
DATA_LOADER_NAME=$$(echo "$$DATA_LOADER_RESPONSE" | jq -r '.result | keys[0]'); \
if [ -n "$$DATA_LOADER_NAME" ] && [ "$$DATA_LOADER_NAME" != "null" ]; then \
echo "📝 Found data loader name: $$DATA_LOADER_NAME"; \
break; \
fi; \
fi; \
RETRY_COUNT=$$((RETRY_COUNT + 1)); \
echo "Retry $$RETRY_COUNT/10: Getting data loader configuration..."; \
sleep 3; \
done; \
if [ $$RETRY_COUNT -eq 10 ]; then \
echo "❌ Failed to get data loader configuration after 10 attempts"; \
exit 1; \
fi; \
echo "🔄 Starting data loading process..."; \
RETRY_COUNT=0; \
while [ $$RETRY_COUNT -lt 10 ]; do \
LOAD_RESULT=$$(curl -s -X POST http://localhost:8080/data-loader/$$DATA_LOADER_NAME/run 2>/dev/null); \
if [ -n "$$LOAD_RESULT" ] && ! echo "$$LOAD_RESULT" | grep -q "Not Found"; then \
echo "✅ Data loading started successfully"; \
break; \
fi; \
RETRY_COUNT=$$((RETRY_COUNT + 1)); \
echo "Retry $$RETRY_COUNT/10: Starting data loading..."; \
sleep 3; \
done; \
if [ $$RETRY_COUNT -eq 10 ]; then \
echo "❌ Failed to start data loading after 10 attempts"; \
exit 1; \
fi
@echo ""
@echo "🎉 Installation completed successfully!"
@echo "📊 System is ready to use."
@echo "🌐 Frontend: http://localhost:3000"
@echo "🌐 Superlinked API: http://localhost:8080"
@echo "🗄️ Qdrant API: http://localhost:6333"
# Start all services with CPU mode
run-cpu:
@echo "🚀 Starting RoleRadar with CPU mode..."
@docker compose -f docker-compose.cpu.yml up -d
@echo "✅ All services started successfully with CPU mode!"
@echo "🌐 Frontend: http://localhost:3000"
@echo "🌐 Superlinked API: http://localhost:8080"
@echo "🗄️ Qdrant API: http://localhost:6333"
# Start all services with GPU mode
run-gpu:
@echo "🚀 Starting RoleRadar with GPU mode..."
@docker compose -f docker-compose.gpu.yml up -d
@echo "✅ All services started successfully with GPU mode!"
@echo "🌐 Frontend: http://localhost:3000"
@echo "🌐 Superlinked API: http://localhost:8080"
@echo "🗄️ Qdrant API: http://localhost:6333"
# Start all services (default)
run:
@echo "🚀 Starting RoleRadar services..."
@if [ -f "docker-compose.cpu.yml" ] && docker compose -f docker-compose.cpu.yml ps superlinked >/dev/null 2>&1; then \
echo "Found running CPU configuration. Starting with CPU mode..."; \
docker compose -f docker-compose.cpu.yml up -d; \
elif [ -f "docker-compose.gpu.yml" ] && docker compose -f docker-compose.gpu.yml ps superlinked >/dev/null 2>&1; then \
echo "Found running GPU configuration. Starting with GPU mode..."; \
docker compose -f docker-compose.gpu.yml up -d; \
else \
echo "No active configuration found. Please select mode:"; \
echo " 1) CPU mode (recommended for most systems)"; \
echo " 2) GPU mode (requires NVIDIA GPU and drivers)"; \
printf "Enter your choice (1 or 2): "; \
read choice; \
if [ "$$choice" = "2" ]; then \
echo "🚀 Starting with GPU mode..."; \
docker compose -f docker-compose.gpu.yml up -d; \
else \
echo "🚀 Starting with CPU mode..."; \
docker compose -f docker-compose.cpu.yml up -d; \
fi; \
fi
@echo "✅ All services started successfully!"
@echo "🌐 Frontend: http://localhost:3000"
@echo "🌐 Superlinked API: http://localhost:8080"
@echo "🗄️ Qdrant API: http://localhost:6333"
# Start only backend services
run-backend:
@echo "🚀 Starting RoleRadar backend services..."
@if [ -f "docker-compose.cpu.yml" ] && docker compose -f docker-compose.cpu.yml ps superlinked >/dev/null 2>&1; then \
echo "Using CPU configuration..."; \
docker compose -f docker-compose.cpu.yml up -d qdrant superlinked; \
elif [ -f "docker-compose.gpu.yml" ] && docker compose -f docker-compose.gpu.yml ps superlinked >/dev/null 2>&1; then \
echo "Using GPU configuration..."; \
docker compose -f docker-compose.gpu.yml up -d qdrant superlinked; \
else \
echo "❌ No active configuration found. Please run 'make install' first."; \
exit 1; \
fi
@echo "✅ Backend services started successfully!"
@echo "🌐 Superlinked API: http://localhost:8080"
@echo "🗄️ Qdrant API: http://localhost:6333"
# Start only frontend service
run-frontend:
@echo "🚀 Starting RoleRadar frontend service..."
@if [ -f "docker-compose.cpu.yml" ] && docker compose -f docker-compose.cpu.yml ps frontend >/dev/null 2>&1; then \
echo "Using CPU configuration..."; \
docker compose -f docker-compose.cpu.yml up -d frontend; \
elif [ -f "docker-compose.gpu.yml" ] && docker compose -f docker-compose.gpu.yml ps frontend >/dev/null 2>&1; then \
echo "Using GPU configuration..."; \
docker compose -f docker-compose.gpu.yml up -d frontend; \
else \
echo "❌ No active configuration found. Please run 'make install' first."; \
exit 1; \
fi
@echo "✅ Frontend service started successfully!"
@echo "🌐 Frontend: http://localhost:3000"
# Stop all services
stop:
@echo "🛑 Stopping all RoleRadar services..."
@docker compose -f docker-compose.cpu.yml down 2>/dev/null || true
@docker compose -f docker-compose.gpu.yml down 2>/dev/null || true
@echo "✅ All services stopped successfully!"
# Stop only backend services
stop-backend:
@echo "🛑 Stopping RoleRadar backend services..."
@docker compose -f docker-compose.cpu.yml stop qdrant superlinked 2>/dev/null || true
@docker compose -f docker-compose.gpu.yml stop qdrant superlinked 2>/dev/null || true
@echo "✅ Backend services stopped successfully!"
# Stop only frontend service
stop-frontend:
@echo "🛑 Stopping RoleRadar frontend service..."
@docker compose -f docker-compose.cpu.yml stop frontend 2>/dev/null || true
@docker compose -f docker-compose.gpu.yml stop frontend 2>/dev/null || true
@echo "✅ Frontend service stopped successfully!"
# Clean up - stop services and remove containers/volumes
clean:
@echo "🧹 Cleaning up RoleRadar environment..."
@docker compose -f docker-compose.cpu.yml down -v --remove-orphans --rmi local 2>/dev/null || true
@docker compose -f docker-compose.gpu.yml down -v --remove-orphans --rmi local 2>/dev/null || true
@echo "✅ Cleanup completed successfully!"
# Show logs from all services
logs:
@echo "📋 Showing logs from all services..."
@if docker compose -f docker-compose.cpu.yml ps >/dev/null 2>&1; then \
docker compose -f docker-compose.cpu.yml logs -f; \
elif docker compose -f docker-compose.gpu.yml ps >/dev/null 2>&1; then \
docker compose -f docker-compose.gpu.yml logs -f; \
else \
echo "❌ No active services found. Please run 'make install' first."; \
fi
# Check service status
status:
@echo "📊 RoleRadar Service Status:"
@echo "=============================="
@if docker compose -f docker-compose.cpu.yml ps >/dev/null 2>&1; then \
echo "Using CPU configuration:"; \
docker compose -f docker-compose.cpu.yml ps; \
elif docker compose -f docker-compose.gpu.yml ps >/dev/null 2>&1; then \
echo "Using GPU configuration:"; \
docker compose -f docker-compose.gpu.yml ps; \
else \
echo "❌ No active configuration found. Please run 'make install' first."; \
exit 1; \
fi
@echo ""
@echo "🔍 Health Check Results:"
@echo "------------------------"
@if curl -s http://localhost:3000 >/dev/null 2>&1; then \
echo "✅ Frontend: HEALTHY (http://localhost:3000)"; \
else \
echo "❌ Frontend: UNAVAILABLE"; \
fi
@if curl -s http://localhost:8080/health >/dev/null 2>&1; then \
echo "✅ Superlinked API: HEALTHY (http://localhost:8080)"; \
else \
echo "❌ Superlinked API: UNAVAILABLE"; \
fi
@if curl -s http://localhost:6333/collections >/dev/null 2>&1; then \
echo "✅ Qdrant API: HEALTHY (http://localhost:6333)"; \
else \
echo "❌ Qdrant API: UNAVAILABLE"; \
fi