Files
kami_gateway/deploy/wait-for-it.sh
danial e88ff05a14 refactor(trace): 重命名 otel 包为 otelTrace并更新相关引用
- 将内部使用的 otel 包重命名为 otelTrace
- 更新了所有引用该包的文件中的导入路径
- 修改了部分函数和变量名称以适应新的包名
2025-02-23 21:56:29 +08:00

53 lines
831 B
Bash

#!/bin/sh
set -e
# 初始化变量
hosts=""
# 解析命令行参数
while [ $# -gt 0 ]; do
case $1 in
-p)
shift
if [ -z "$1" ]; then
echo "No host:port provided after -p"
exit 1
fi
hosts="$hosts $1"
;;
-* | --*)
echo "Unknown option $1"
exit 1
;;
*)
break
;;
esac
shift
done
# 检查是否提供了主机
if [ -z "$hosts" ]; then
echo "No hosts provided. Exiting."
exit 1
fi
# 等待所有服务变得可用
for host in $hosts; do
addr=$(echo $host | cut -d':' -f1)
port=$(echo $host | cut -d':' -f2)
while ! nc -z "$addr" "$port"; do
echo "Waiting for $addr:$port..." >&2
sleep 1
done
echo "$addr:$port is available!"
done
# 执行最终命令
if [ $# -eq 0 ]; then
echo "No command provided to execute. Exiting."
exit 1
fi
exec "$@"