项目作者: andreiavrammsd

项目描述 :
Run a command only when port on host is available
高级语言: Shell
项目地址: git://github.com/andreiavrammsd/wait-for-it.git
创建时间: 2016-12-27T21:35:00Z
项目社区:https://github.com/andreiavrammsd/wait-for-it

开源协议:MIT License

下载


Wait for it

Run a command only when port on host is available

Tested on Alpine and Ubuntu

I needed to run a command in an Alpine Docker container only after another process (from other container) was open.

Based on https://github.com/vishnubob/wait-for-it. Many thanks!

Uses: https://en.wikipedia.org/wiki/Netcat

Setup

  • chmod +x wait-for-it.sh
  • Change shebang line as needed:
    • Alpine: #!/usr/bin/env sh
    • Ubuntu: #!/usr/bin/env bash

Usage

  1. ./wait-for-it.sh -h host -p port [-c command] [-t timeout] [-q quiet]
  2. -h Host or IP under test
  3. -p TCP port under test
  4. -c Command to execute if test succeeds
  5. -t Timeout in seconds, zero for no timeout
  6. -q Don't output any status messages

Examples

  1. ./wait-for-it.sh -h www.google.com -p 80 -t 5 -c "echo Google is up" -q
  2. ./wait-for-it.sh -h www.google.com -p 8080 -t 5

Other

See this, too: https://github.com/jwilder/dockerize