-
Notifications
You must be signed in to change notification settings - Fork 2
MySQL
dm03514 edited this page Aug 29, 2018
·
2 revisions
$ ./bin/wait-for mysql --help
NAME:
wait-for mysql -
USAGE:
wait-for mysql [command options] [arguments...]
OPTIONS:
--connection-string value, --cs value mysql connection string [$WAIT_FOR_MYSQL_CONNECTION_STRING]
- Start waiting
$ export WAIT_FOR_MYSQL_CONNECTION_STRING=root:root@/performance_schema
$ ./bin/wait-for --poll-interval=1s mysql
{"level":"info","msg":"polling","time":"2018-08-28T20:17:32Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:17:32Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:17:33Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:17:33Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:17:34Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:17:34Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:17:35Z"}
[mysql] 2018/08/28 20:17:35 packets.go:36: unexpected EOF
[mysql] 2018/08/28 20:17:35 packets.go:36: unexpected EOF
[mysql] 2018/08/28 20:17:35 packets.go:36: unexpected EOF
{"err":"driver: bad connection","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:17:35Z"}
....
- Start mysql
vagrant@ubuntu-xenial:/vagrant_data/go/src/github.com/dm03514/wait-for/tests/mysql⟫ docker-compose down && docker-compose up
- When mysql is initialized logs of wait-for
{"err":"driver: bad connection","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:17:44Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:17:45Z"}
[mysql] 2018/08/28 20:17:45 packets.go:36: unexpected EOF
[mysql] 2018/08/28 20:17:45 packets.go:36: unexpected EOF
[mysql] 2018/08/28 20:17:45 packets.go:36: unexpected EOF
{"err":"driver: bad connection","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:17:45Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:17:46Z"}
{"err":null,"level":"debug","msg":"poll_result","ready":true,"time":"2018-08-28T20:17:46Z"}
- No MySQL up timeout reached
$ export WAIT_FOR_MYSQL_CONNECTION_STRING=root:root@/performance_schema
$ ./bin/wait-for --timeout=1s --poll-interval=250ms mysql
{"level":"info","msg":"polling","time":"2018-08-28T20:16:12Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:16:12Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:16:12Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:16:12Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:16:13Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:16:13Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:16:13Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:16:13Z"}
{"level":"info","msg":"polling","time":"2018-08-28T20:16:13Z"}
{"err":"dial tcp 127.0.0.1:3306: connect: connection refused","level":"debug","msg":"poll_result","ready":false,"time":"2018-08-28T20:16:13Z"}
{"level":"info","msg":"timeout_reached","time":"2018-08-28T20:16:13Z"}
{"level":"fatal","msg":"timeout reached: 1s","time":"2018-08-28T20:16:13Z"}
$ echo $?
1