1 Star 0 Fork 0

kyell/deploy_bubble_using_docker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wait-for.sh 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
Q1mi 提交于 2020-04-23 17:10 +08:00 . upload code ...
#!/bin/bash
TIMEOUT=15
QUIET=0
ADDRS=()
echoerr() {
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
}
usage() {
exitcode="$1"
cat << USAGE >&2
client:
$cmdname host:port [host:port] [host:port] [-t timeout] [-- command args]
-q | --quiet Do not output any status messages
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit "$exitcode"
}
wait_for() {
results=()
for addr in ${ADDRS[@]}
do
HOST=$(printf "%s\n" "$addr"| cut -d : -f 1)
PORT=$(printf "%s\n" "$addr"| cut -d : -f 2)
result=1
for i in `seq $TIMEOUT` ; do
nc -z "$HOST" "$PORT" > /dev/null 2>&1
result=$?
if [ $result -ne 0 ] ; then
sleep 1
continue
fi
break
done
results=(${results[@]} $result)
done
num=${#results[@]}
for result in ${results[@]}
do
if [ $result -eq 0 ] ; then
num=`expr $num - 1`
fi
done
if [ $num -eq 0 ] ; then
if [ $# -gt 0 ] ; then
exec "$@"
fi
exit 0
fi
echo "Operation timed out" >&2
exit 1
}
while [ $# -gt 0 ]
do
case "$1" in
*:* )
ADDRS=(${ADDRS[@]} $1)
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-t)
TIMEOUT="$2"
if [ "$TIMEOUT" = "" ]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
break
;;
--help)
usage 0
;;
*)
echoerr "Unknown argument: $1"
usage 1
;;
esac
done
if [ "${#ADDRS[@]}" -eq 0 ]; then
echoerr "Error: you need to provide a host and port to test."
usage 2
fi
wait_for "$@"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yu_bind/deploy_bubble_using_docker.git
git@gitee.com:yu_bind/deploy_bubble_using_docker.git
yu_bind
deploy_bubble_using_docker
deploy_bubble_using_docker
master

搜索帮助