-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
189 lines (168 loc) · 5.89 KB
/
Makefile
File metadata and controls
189 lines (168 loc) · 5.89 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
# Sentinel API Testing Platform - Makefile
# Convenient commands for development and deployment
.PHONY: help init-db reset-db start stop restart logs test clean db-health db-diagnostics
# Default target
help:
@echo "Sentinel API Testing Platform - Available Commands:"
@echo ""
@echo "Database Management:"
@echo " make init-db - Initialize database with retry logic"
@echo " make db-health - Check database health status"
@echo " make db-diagnostics - Run comprehensive database diagnostics"
@echo " make db-ready - Wait for database to be ready"
@echo " make reset-db - Drop and recreate database (WARNING: data loss)"
@echo " make backup-db - Backup database to file"
@echo " make restore-db - Restore database from backup"
@echo ""
@echo "Service Management:"
@echo " make start - Start all services"
@echo " make stop - Stop all services"
@echo " make restart - Restart all services"
@echo " make logs - Show logs from all services"
@echo " make status - Show service status"
@echo ""
@echo "Development:"
@echo " make test - Run tests"
@echo " make clean - Clean up containers and volumes"
@echo " make build - Build all Docker images"
@echo " make dev - Start in development mode"
@echo ""
@echo "Quick Start:"
@echo " make setup - Complete setup (build, init-db, start)"
# Enhanced database initialization with retry logic
init-db:
@echo "=========================================="
@echo "Database Initialization with Retry Logic"
@echo "=========================================="
@python3 sentinel_backend/scripts/init_db_with_retry.py
@echo ""
@echo "Verifying initialization..."
@python3 sentinel_backend/scripts/db_health_check.py --readiness
@echo "✅ Database initialization complete!"
# Database health check
db-health:
@echo "=========================================="
@echo "Database Health Check"
@echo "=========================================="
@python3 sentinel_backend/scripts/db_health_check.py --detailed
# Comprehensive database diagnostics
db-diagnostics:
@echo "=========================================="
@echo "Database Diagnostics"
@echo "=========================================="
@python3 sentinel_backend/scripts/db_diagnostics.py
# Wait for database to be ready
db-ready:
@echo "Waiting for database to be ready..."
@python3 sentinel_backend/scripts/db_health_check.py --readiness
@echo "✅ Database is ready!"
# Reset database (WARNING: destroys all data)
reset-db:
@echo "=========================================="
@echo "⚠️ WARNING: DATABASE RESET"
@echo "=========================================="
@echo "This will DELETE ALL DATA!"
@echo "Press Ctrl+C to cancel, or wait 5 seconds..."
@sleep 5
@echo ""
@echo "Dropping database..."
@docker-compose exec -T db psql -U postgres -c "DROP DATABASE IF EXISTS sentinel_db;" || true
@docker-compose exec -T db psql -U postgres -c "CREATE DATABASE sentinel_db OWNER sentinel;" || true
@echo ""
@echo "Recreating database..."
@docker-compose exec -T db psql -U sentinel sentinel_db -c "CREATE EXTENSION IF NOT EXISTS vector;" || true
@echo ""
@make init-db
# Backup database
backup-db:
@echo "=========================================="
@echo "Database Backup"
@echo "=========================================="
@mkdir -p backups
@docker-compose exec -T db pg_dump -U sentinel sentinel_db > backups/sentinel_db_$(shell date +%Y%m%d_%H%M%S).sql
@echo "Database backed up to backups/"
# Restore database from latest backup
restore-db:
@echo "Restoring database from latest backup..."
@docker-compose exec -T db psql -U sentinel sentinel_db < $(shell ls -t backups/*.sql | head -1)
@echo "Database restored!"
# Start all services
start:
@echo "Starting all services..."
@docker-compose up -d
@echo "Waiting for services to be ready..."
@sleep 10
@make init-db
@echo "Starting frontend..."
@cd sentinel_frontend && nohup npm start > /tmp/frontend.log 2>&1 &
@echo "All services started!"
@echo ""
@echo "Access points:"
@echo " Frontend: http://localhost:3000"
@echo " API Gateway: http://localhost:8000"
@echo " Petstore: http://localhost:8080"
@echo ""
@echo "Login: admin@sentinel.com / admin123"
# Stop all services
stop:
@echo "Stopping all services..."
@docker-compose down
@pkill -f "react-scripts" || true
@echo "All services stopped!"
# Restart all services
restart:
@make stop
@make start
# Show logs
logs:
@docker-compose logs -f --tail=50
# Show service status
status:
@echo "Service Status:"
@docker-compose ps
@echo ""
@echo "Frontend Status:"
@ps aux | grep -E "react-scripts" | grep -v grep || echo "Frontend not running"
# Build Docker images
build:
@echo "Building Docker images..."
@docker-compose build --no-cache
@echo "Build complete!"
# Clean up everything
clean:
@echo "Cleaning up containers and volumes..."
@docker-compose down -v
@docker volume prune -f
@docker network prune -f
@rm -rf backups/
@echo "Cleanup complete!"
# Run tests
test:
@echo "Running tests..."
@docker-compose exec -T orchestration_service pytest tests/ || true
@docker-compose exec -T data_service pytest tests/ || true
@echo "Tests complete!"
# Development mode
dev:
@echo "Starting in development mode..."
@docker-compose up -d db message_broker
@sleep 5
@make init-db
@docker-compose up
# Complete setup from scratch
setup:
@echo "Setting up Sentinel from scratch..."
@make build
@make start
@echo ""
@echo "✅ Setup complete!"
@echo "Access the application at: http://localhost:3000"
@echo "Login with: admin@sentinel.com / admin123"
# Start Petstore test application
start-petstore:
@echo "Starting Petstore test application..."
@cd petstore_api && docker-compose up -d
@echo "Petstore running at: http://localhost:8080"
# Stop Petstore
stop-petstore:
@cd petstore_api && docker-compose down