-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.sh
More file actions
66 lines (57 loc) · 1.83 KB
/
Copy pathstart.sh
File metadata and controls
66 lines (57 loc) · 1.83 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
#!/bin/bash
set -euo pipefail
is_docker_running() {
docker info > /dev/null 2>&1
}
port_in_use() {
local port=$1
if command -v netstat > /dev/null 2>&1; then
netstat -an 2>/dev/null | grep -q "[.:]${port} .*LISTEN"
return $?
fi
return 1
}
echo "🔍 Checking if Docker is running..."
if ! is_docker_running; then
echo "❌ Docker is not running. Attempting to start it..."
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
powershell.exe -Command "Start-Process 'C:\Program Files\Docker\Docker\Docker Desktop.exe'" || true
elif [[ "$OSTYPE" == "darwin"* ]]; then
open -a Docker || true
fi
counter=0
until is_docker_running || [ $counter -eq 24 ]; do
sleep 5
counter=$((counter + 1))
echo "Still waiting... ($((counter * 5))s)"
done
if ! is_docker_running; then
echo "🚨 Failed to start Docker. Please start it manually."
exit 1
fi
fi
echo "✅ Docker is running."
PROFILE="default"
if port_in_use 6379; then
echo "⚠️ Port 6379 is already in use (existing Redis detected)."
echo " Using external profile — proxy will connect to host Redis on :6379"
PROFILE="external"
fi
echo "🚀 Starting with profile: $PROFILE"
if [ "$PROFILE" = "external" ]; then
docker compose --profile external up -d --build upstash-local-external
else
docker compose up -d --build
fi
if [ $? -ne 0 ]; then
echo "🚨 docker compose failed. Check errors above."
exit 1
fi
echo ""
echo "✅ Upstash Redis Local is running!"
echo "🔗 REST API: http://localhost:8000/PING?_token=local-dev-token"
echo "🔗 Dashboard: http://localhost:8000/dashboard"
echo "🔗 Health: http://localhost:8000/health"
echo "🔗 Redis: localhost:6379"
echo ""
echo "💡 Unlimited local requests — no cloud rate limits."