test.sh 476 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. wait_for() {
  3. host="${1}"
  4. port="${2}"
  5. name="${3}"
  6. timeout="${4:-30}"
  7. printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
  8. i=0
  9. while ! nc -z "${host}" "${port}"; do
  10. sleep 1
  11. if [ "$i" -gt "$timeout" ]; then
  12. printf "Timed out!\n"
  13. return 1
  14. fi
  15. i="$((i + 1))"
  16. done
  17. printf "OK\n"
  18. }
  19. netdata -D > netdata.log 2>&1 &
  20. wait_for localhost 19999 netdata
  21. curl -sS http://127.0.0.1:19999/api/v1/info | jq '.version'