diff --git a/scripts/dev.sh b/scripts/dev.sh index 6fee513..66268f9 100755 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -86,7 +86,15 @@ free_8080 # out with no hint as to why. The per-container `.orb.local` name resolves to # the default bridge instead, which is always routed, so it goes first, with # the inspected addresses as the fallback for other runtimes. -db_reachable() { nc -z -G 2 -w 2 "$1" 5432 >/dev/null 2>&1; } +# macOS nc needs -G to bound a connect to an unroutable host (-w alone hangs +# there); OpenBSD nc has no -G and bounds it with -w. Probe once rather than +# branching on uname, or every candidate reads as dead on the wrong platform. +if nc -G 1 -z 127.0.0.1 1 2>&1 | grep -q 'invalid option'; then + nc_timeout_flags="-w 2" +else + nc_timeout_flags="-G 2 -w 2" +fi +db_reachable() { nc -z $nc_timeout_flags "$1" 5432 >/dev/null 2>&1; } if [ -z "${DATABASE_URL:-}" ]; then db_cid="$(docker compose ps -q db 2>/dev/null | head -n1)"