90-netdata-runtime-check.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. # shellcheck source=./packaging/makeself/functions.sh
  4. . "${NETDATA_MAKESELF_PATH}"/functions.sh "${@}" || exit 1
  5. dump_log() {
  6. cat ./netdata.log
  7. }
  8. wait_for() {
  9. host="${1}"
  10. port="${2}"
  11. name="${3}"
  12. timeout="30"
  13. if command -v nc > /dev/null ; then
  14. netcat="nc"
  15. elif command -v netcat > /dev/null ; then
  16. netcat="netcat"
  17. else
  18. printf "Unable to find a usable netcat command.\n"
  19. return 1
  20. fi
  21. printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
  22. sleep 30
  23. i=0
  24. while ! ${netcat} -z "${host}" "${port}"; do
  25. sleep 1
  26. if [ "$i" -gt "$timeout" ]; then
  27. printf "Timed out!\n"
  28. return 1
  29. fi
  30. i="$((i + 1))"
  31. done
  32. printf "OK\n"
  33. }
  34. trap dump_log EXIT
  35. "${NETDATA_INSTALL_PATH}/bin/netdata" -D > ./netdata.log 2>&1 &
  36. wait_for localhost 19999 netdata || exit 1
  37. curl -sS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
  38. cat ./response
  39. jq '.version' ./response || exit 1
  40. trap - EXIT