don't try to use lsof on Windows (#2762)

This commit is contained in:
Ștefan Talpalaru 2021-08-05 10:49:34 +02:00 committed by GitHub
parent c4bf4f8fff
commit 59b1a4772c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 25 deletions

View File

@ -187,12 +187,14 @@ mkdir -p "${NETWORK_DIR}"
USER_VALIDATORS=8 USER_VALIDATORS=8
TOTAL_VALIDATORS=128 TOTAL_VALIDATORS=128
HAVE_LSOF=0
# Windows detection # Windows detection
if uname | grep -qiE "mingw|msys"; then if uname | grep -qiE "mingw|msys"; then
MAKE="mingw32-make" MAKE="mingw32-make"
else else
MAKE="make" MAKE="make"
which lsof &>/dev/null && HAVE_LSOF=1 || { echo "'lsof' not installed and we need it to check for ports already in use. Aborting."; exit 1; }
fi fi
# number of CPU cores # number of CPU cores
@ -203,8 +205,8 @@ else
fi fi
# kill lingering processes from a previous run # kill lingering processes from a previous run
which lsof &>/dev/null || { echo "'lsof' not installed. Aborting."; exit 1; } if [[ "${HAVE_LSOF}" == "1" ]]; then
for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
for PORT in $(( BASE_PORT + NUM_NODE )) $(( BASE_METRICS_PORT + NUM_NODE )) $(( BASE_RPC_PORT + NUM_NODE )); do for PORT in $(( BASE_PORT + NUM_NODE )) $(( BASE_METRICS_PORT + NUM_NODE )) $(( BASE_RPC_PORT + NUM_NODE )); do
for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do
echo -n "Found old process listening on port ${PORT}, with PID ${PID}. " echo -n "Found old process listening on port ${PORT}, with PID ${PID}. "
@ -217,7 +219,8 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
fi fi
done done
done done
done done
fi
# Build the binaries # Build the binaries
BINARIES="nimbus_beacon_node nimbus_signing_process nimbus_validator_client deposit_contract" BINARIES="nimbus_beacon_node nimbus_signing_process nimbus_validator_client deposit_contract"

View File

@ -115,11 +115,14 @@ MKDIR_SCRIPT="${GIT_ROOT}/scripts/makedir.sh"
$MKDIR_SCRIPT "${TEST_DIR}" $MKDIR_SCRIPT "${TEST_DIR}"
HAVE_LSOF=0
# Windows detection # Windows detection
if uname | grep -qiE "mingw|msys"; then if uname | grep -qiE "mingw|msys"; then
MAKE="mingw32-make" MAKE="mingw32-make"
else else
MAKE="make" MAKE="make"
which lsof &>/dev/null && HAVE_LSOF=1 || { echo "'lsof' not installed and we need it to check for ports already in use. Aborting."; exit 1; }
fi fi
# number of CPU cores # number of CPU cores
@ -130,8 +133,8 @@ else
fi fi
# kill lingering processes from a previous run # kill lingering processes from a previous run
which lsof &>/dev/null || { echo "'lsof' not installed. Aborting."; exit 1; } if [[ "${HAVE_LSOF}" == "1" ]]; then
for PORT in ${BASE_PORT} ${BASE_METRICS_PORT} ${BASE_REST_PORT}; do for PORT in ${BASE_PORT} ${BASE_METRICS_PORT} ${BASE_REST_PORT}; do
for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do
echo -n "Found old process listening on port ${PORT}, with PID ${PID}. " echo -n "Found old process listening on port ${PORT}, with PID ${PID}. "
if [[ "${KILL_OLD_PROCESSES}" == "1" ]]; then if [[ "${KILL_OLD_PROCESSES}" == "1" ]]; then
@ -142,7 +145,8 @@ for PORT in ${BASE_PORT} ${BASE_METRICS_PORT} ${BASE_REST_PORT}; do
exit 1 exit 1
fi fi
done done
done done
fi
build_if_missing () { build_if_missing () {
if [[ ! -e "${GIT_ROOT}/build/${1}" ]]; then if [[ ! -e "${GIT_ROOT}/build/${1}" ]]; then