examples/read-consul/koanfconsul.sh
raw| 1 | consul agent -dev & |
| 2 | |
| 3 | exitcode=1 |
| 4 | iterations=0 |
| 5 | |
| 6 | while [ $exitcode -ne 0 ] |
| 7 | do |
| 8 | consul members |
| 9 | exitcode=$? |
| 10 | |
| 11 | sleep 1 |
| 12 | ((iterations++)) |
| 13 | |
| 14 | if [ $iterations -gt 5 ]; then |
| 15 | break |
| 16 | fi |
| 17 | done |
| 18 | |
| 19 | if [ $exitcode -eq 0 ]; then |
| 20 | echo -e "\nTest program running..." |
| 21 | go run main.go |
| 22 | echo -e "\nShutdown..." |
| 23 | consul leave |
| 24 | else |
| 25 | echo "Consul server is unavailable." |
| 26 | consul leave |
| 27 | fi |