fix to use with sveltekit
This commit is contained in:
32
bin/helper/wait
Executable file
32
bin/helper/wait
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
: ${SLEEP_LENGTH:=2}
|
||||
: ${TIMEOUT_LENGTH:=60}
|
||||
|
||||
DIR="$(cd $(dirname $0) && pwd)"
|
||||
BIN_DIR="$(cd $DIR/.. && pwd)"
|
||||
|
||||
# Import functions
|
||||
. $BIN_DIR/helper/fn
|
||||
|
||||
wait_for() {
|
||||
START="$(date +%s)"
|
||||
echo "Waiting for $1 to listen on $2..."
|
||||
while ! nc -z $1 $2; do
|
||||
if [ $(($(date +%s) - $START)) -gt $TIMEOUT_LENGTH ]; then
|
||||
abort "Service $1:$2 did not start within $TIMEOUT_LENGTH seconds. Aborting..."
|
||||
fi
|
||||
echo "sleeping"
|
||||
sleep $SLEEP_LENGTH
|
||||
done
|
||||
}
|
||||
|
||||
for var in "$@"
|
||||
do
|
||||
host=${var%:*}
|
||||
port=${var#*:}
|
||||
wait_for $host $port
|
||||
ok "Listening ${host}:${port}"
|
||||
done
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user