File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,13 @@ wait_for()
3232 start_ts=$( date +%s)
3333 while :
3434 do
35- (echo > /dev/tcp/$HOST /$PORT ) > /dev/null 2>&1
36- result=$?
35+ if [[ $ISBUSY -eq 1 ]]; then
36+ nc -z $HOST $PORT
37+ result=$?
38+ else
39+ (echo > /dev/tcp/$HOST /$PORT ) > /dev/null 2>&1
40+ result=$?
41+ fi
3742 if [[ $result -eq 0 ]]; then
3843 end_ts=$( date +%s)
3944 echoerr " $cmdname : $HOST :$PORT is available after $(( end_ts - start_ts)) seconds"
@@ -48,9 +53,9 @@ wait_for_wrapper()
4853{
4954 # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
5055 if [[ $QUIET -eq 1 ]]; then
51- timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
56+ timeout $BUSYTIMEFLAG $ TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
5257 else
53- timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
58+ timeout $BUSYTIMEFLAG $ TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
5459 fi
5560 PID=$!
5661 trap " kill -INT -$PID " INT
@@ -136,6 +141,17 @@ STRICT=${STRICT:-0}
136141CHILD=${CHILD:- 0}
137142QUIET=${QUIET:- 0}
138143
144+ # check to see if timeout is from busybox?
145+ # check to see if timeout is from busybox?
146+ TIMEOUT_PATH=$( realpath $( which timeout) )
147+ if [[ $TIMEOUT_PATH =~ " busybox" ]]; then
148+ ISBUSY=1
149+ BUSYTIMEFLAG=" -t"
150+ else
151+ ISBUSY=0
152+ BUSYTIMEFLAG=" "
153+ fi
154+
139155if [[ $CHILD -gt 0 ]]; then
140156 wait_for
141157 RESULT=$?
You can’t perform that action at this time.
0 commit comments