在 .sh 文件中 运行 时找不到等待命令

wait-for-it Command not found when run inside a .sh file

假设我正在执行一个名为 run.sh 的文件。我在这个文件中有这个命令:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it ${SERVER}

当我 echo ${SERVER} 时,我可以看到它已正确设置为 newserver:5555。当我 运行 run.sh 文件时,我得到这个错误:

Command 'newserver:5555' not found

我做错了什么?

更新:“wait-for-it 是一个脚本,它将在执行用户定义的命令之前等待一个或多个 TCP 服务(即 host:port)的可用性。”

来自您链接的wait-for-it website

Usage: wait-for-it [OPTIONS] [COMMANDS]...

  Wait for service(s) to be available before executing a command.

Options:
  -h, --help               Show this message and exit.
  -v, --version            Show the version and exit.
  -q, --quiet              Do not output any status messages
  -p, --parallel           Test services in parallel rather than in serial
  -t, --timeout seconds    Timeout in seconds, 0 for no timeout  [default: 15]
  -s, --service host:port  Services to test, in one of the formats: ':port',
                           'hostname:port', 'v4addr:port', '[v6addr]:port' or
                           'https://...'

所以你可能想要:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it --service ${SERVER}