Skip to content
dm03514 edited this page Sep 8, 2018 · 5 revisions
$ ./bin/wait-for redis --help
NAME:
   wait-for redis -

USAGE:
   wait-for redis [command options] [arguments...]

OPTIONS:
   --address value, -a value   redis address and port "addr:port" (default: "localhost:6379")
   --password value, -p value  redis password
   --db value                  redis db to connect to (default: 0)

Success

  • Start waiting
$ ./bin/wait-for --poll-interval=1s redis --address=localhost:6379 --password="" --db=0
{"level":"info","msg":"polling","time":"2018-09-08T19:07:29Z"}
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T19:07:29Z"}
{"level":"info","msg":"polling","time":"2018-09-08T19:07:30Z"}
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T19:07:30Z"}
{"level":"info","msg":"polling","time":"2018-09-08T19:07:31Z"}
  • Start Redis
vagrant@ubuntu-xenial:/vagrant_data/go/src/github.com/dm03514/wait-for/tests/redis⟫ docker-compose down && docker-compose up
Removing redis_postgres_1 ... done
Removing network redis_default
WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

Creating network "redis_default" with the default driver
Creating redis_postgres_1 ... done
Attaching to redis_postgres_1
postgres_1  | 1:C 08 Sep 19:07:31.859 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
postgres_1  | 1:C 08 Sep 19:07:31.859 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
postgres_1  | 1:C 08 Sep 19:07:31.859 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
postgres_1  | 1:M 08 Sep 19:07:31.860 * Running mode=standalone, port=6379.
postgres_1  | 1:M 08 Sep 19:07:31.860 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
postgres_1  | 1:M 08 Sep 19:07:31.860 # Server initialized
postgres_1  | 1:M 08 Sep 19:07:31.860 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
postgres_1  | 1:M 08 Sep 19:07:31.860 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
postgres_1  | 1:M 08 Sep 19:07:31.860 * Ready to accept connections
  • Log Output when redis is initialized
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T19:07:31Z"}
{"level":"info","msg":"polling","time":"2018-09-08T19:07:32Z"}
{"err":null,"level":"debug","msg":"poll_result","ready":true,"time":"2018-09-08T19:07:32Z"}

Timeout

$ ./bin/wait-for --poll-interval=250ms --timeout=1s redis --address=localhost:6379 --password="" --db=0
{"level":"info","msg":"polling","time":"2018-09-08T17:17:17Z"}
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T17:17:17Z"}
{"level":"info","msg":"polling","time":"2018-09-08T17:17:17Z"}
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T17:17:17Z"}
{"level":"info","msg":"polling","time":"2018-09-08T17:17:18Z"}
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T17:17:18Z"}
{"level":"info","msg":"polling","time":"2018-09-08T17:17:18Z"}
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T17:17:18Z"}
{"level":"info","msg":"polling","time":"2018-09-08T17:17:18Z"}
{"err":"dial tcp 127.0.0.1:6379: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-09-08T17:17:18Z"}
{"level":"info","msg":"timeout_reached","time":"2018-09-08T17:17:18Z"}
{"level":"fatal","msg":"timeout reached: 1s","time":"2018-09-08T17:17:18Z"}
Clone this wiki locally