wait-for-it
wait-for-it copied to clipboard
Use nc command if it exists and specify explicit connection timeout to avoid hanging
Use nc command if it exists.
Add explicit connection timeout of 10 seconds, because, depending on the system, nc command could be a symlink to netcat or Ncat program (a netcat re-implementation), and Ncat has a default connection timeout od 10 seconds (thus this value was chosen), while netcat has infinite connection timeout by default. Infinite connection timeout resulted in wait-for-it.sh to hang and never succeed to connect to target host if it wasn't reachable initially but became reachable a bit later (for example when starting docker containers), until main wait-for-it.sh timeout expired, at which point it is too late.
The same timeout value of 10 seconds is also added to network redirection for the same reason.