github.com/go-graphite/carbonapi@v0.17.0/cmd/carbonapi/config_tests/common.sh (about) 1 #!/usr/bin/env bash 2 3 _RUNNING_OS=$(uname -s) 4 5 function get_listeners() { 6 case "${_RUNNING_OS}" in 7 "Linux") 8 ss -ltpn | grep "${1}" | awk '{print $4}' | sort -u 9 ;; 10 "Darwin") 11 lsof -nP -iTCP -sTCP:LISTEN | grep "${1}" | awk '{print $9}' | sort -u 12 ;; 13 *) 14 echo "OS ${_RUNNING_OS} currently not supported to run this test" >2 15 exit 130 16 ;; 17 esac 18 } 19 20 cleanup() { 21 local pids=$(jobs -pr) 22 if [[ -n "${pids}" ]]; then 23 kill -9 ${pids} 2>/dev/null ||: 24 fi 25 }