-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
53 lines (44 loc) · 1.38 KB
/
start.sh
File metadata and controls
53 lines (44 loc) · 1.38 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
#!/usr/bin/env bash
set -euo pipefail
# Load .env defaults
if [ -f .env ]; then
set -a
source .env
set +a
fi
# Check if a port is available
is_port_free() {
! ss -tlnH "sport = :$1" 2>/dev/null | grep -q .
}
# Find first available port from a list, returns the chosen port
find_free_port() {
local service_name="$1"
shift
for port in "$@"; do
if is_port_free "$port"; then
echo "$port"
return 0
fi
done
echo "ERROR: No free port found for $service_name (tried: $*)" >&2
return 1
}
echo "=== SQL Playgrounds - Starting ==="
echo ""
# Resolve ports with fallbacks
POSTGRES_PORT=$(find_free_port "PostgreSQL" "${POSTGRES_PORT:-5432}" 5433 5434)
PGADMIN_PORT=$(find_free_port "PGAdmin" "${PGADMIN_PORT:-8080}" 8081 8082)
SUPERSET_PORT=$(find_free_port "Superset" "${SUPERSET_PORT:-8088}" 8089 8090)
export POSTGRES_PORT PGADMIN_PORT SUPERSET_PORT
echo "Ports:"
echo " PostgreSQL : $POSTGRES_PORT"
echo " PGAdmin : $PGADMIN_PORT -> http://localhost:$PGADMIN_PORT"
echo " Superset : $SUPERSET_PORT -> http://localhost:$SUPERSET_PORT"
echo ""
# Pass through any extra args (e.g. --build, -d)
docker-compose up -d --build "$@"
echo ""
echo "=== All services started ==="
echo " PGAdmin : http://localhost:$PGADMIN_PORT"
echo " Superset : http://localhost:$SUPERSET_PORT"
echo " Postgres : localhost:$POSTGRES_PORT"