-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
38 lines (33 loc) · 1.11 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
38 lines (33 loc) · 1.11 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
#!/bin/sh
set -e
# P2P rooms live in process memory — multiple aird instances behind round-robin break
# anonymous share links (sender on worker A, recipient hits worker B). Default to one
# instance; set AIRD_DOCKER_INSTANCES>1 only if you accept broken P2P or add shared state.
CORES="${AIRD_DOCKER_INSTANCES:-1}"
if [ "$CORES" -lt 1 ]; then
CORES=1
fi
if [ "$CORES" -gt 1 ]; then
echo "WARNING: $CORES aird instances — in-memory P2P rooms are not shared across workers."
fi
echo "Starting $CORES aird instance(s)..."
UPSTREAMS=""
for i in $(seq 1 $CORES); do
PORT=$((7999 + i))
echo "Starting aird instance $i on port $PORT..."
python -m aird --port $PORT --multi-user --root "${AIRD_ROOT:-/project_root}" &
UPSTREAMS="$UPSTREAMS 127.0.0.1:$PORT"
done
# Wait for aird instances to be ready
sleep 3
# Generate actual Caddyfile with load balancing
cat > /etc/caddy/Caddyfile <<EOF
:80 {
reverse_proxy $UPSTREAMS {
lb_policy round_robin
}
}
EOF
# Start Caddy in foreground (gateway on port 80)
echo "Starting Caddy load balancer on port 80..."
exec caddy run --config /etc/caddy/Caddyfile