This repository was archived by the owner on Apr 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathrun-debug.sh
More file actions
executable file
·89 lines (71 loc) · 2.6 KB
/
run-debug.sh
File metadata and controls
executable file
·89 lines (71 loc) · 2.6 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
#!/bin/sh
# Check if Docker is running
check_docker() {
if ! docker info >/dev/null 2>&1; then
echo "❌ Error: Docker is not running or not accessible"
echo "Please start Docker and try again"
exit 1
fi
echo "✅ Docker is running"
}
# Check if required ports are available (after Docker shutdown)
check_ports() {
local ports="5432 6379" # PostgreSQL and Redis
local failed_ports=""
for port in $ports; do
if lsof -i :$port >/dev/null 2>&1; then
failed_ports="$failed_ports $port"
fi
done
if [ ! -z "$failed_ports" ]; then
echo "❌ Error: Required ports are still in use by external processes:$failed_ports"
echo "Please stop the services using these ports:"
for port in $failed_ports; do
echo " Port $port: $(lsof -i :$port | tail -n +2 | awk '{print $1}' | sort -u | tr '\n' ' ')"
done
echo "Then try again."
exit 1
fi
echo "✅ Required ports (5432, 6379) are available"
}
# Check Docker status first
check_docker
# Stop any existing services first (this might free up the ports)
echo "🛑 Stopping any existing Docker services..."
docker-compose -f docker-compose-local-debug.yaml down
# Now check if ports are still blocked by external processes
check_ports
# Start services in the background
echo "🚀 Starting Docker services..."
docker-compose -f docker-compose-local-debug.yaml up --build -d
echo "Starting services..."
# Wait for PostgreSQL to be ready
for i in {1..10}; do
if docker-compose -f docker-compose-local-debug.yaml exec postgres pg_isready -U postgres > /dev/null 2>&1; then
break
fi
echo "Waiting for PostgreSQL to be ready... ($i/10)"
sleep 1
done
# Wait for Redis to be ready
for i in {1..5}; do
if docker-compose -f docker-compose-local-debug.yaml exec redis redis-cli ping > /dev/null 2>&1; then
break
fi
echo "Waiting for Redis to be ready... ($i/5)"
sleep 1
done
echo "Services are ready! Setting up Prisma..."
# Create necessary directories for Prisma
mkdir -p generated/prisma/runtime || { echo "Failed to create Prisma directories"; exit 1; }
chmod -R 777 generated || { echo "Failed to set permissions"; exit 1; }
# Generate Prisma client and run migrations
echo "Generating Prisma client..."
npx prisma generate || { echo "Prisma client generation failed"; exit 1; }
echo "Running Prisma migrations..."
npx prisma migrate deploy || { echo "Prisma migrations failed"; exit 1; }
echo "Prisma setup complete! Starting Next.js development server..."
# Upload schema changes to the database first
yarn prisma db push || { echo "Prisma db push failed"; exit 1; }
# Run the Next.js development server
yarn dev