From 82ed7e232e5ead30b09559dc778e6f46356915f0 Mon Sep 17 00:00:00 2001 From: MarceloDamian <60354250+MarceloDamian@users.noreply.github.com> Date: Fri, 8 May 2020 12:34:11 -0400 Subject: [PATCH] fix(cypress): revised kill signals to processes in e2e.sh (#38692) --- cypress/run-e2e.sh | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cypress/run-e2e.sh b/cypress/run-e2e.sh index 4ee83a4860..9c4b926262 100755 --- a/cypress/run-e2e.sh +++ b/cypress/run-e2e.sh @@ -11,24 +11,23 @@ finally() { local exit_code="${1:-0}" # This is the clean up. - # Find any node processes running from within the client dir - local hanging_client_processes=$(ps aux | grep -v grep | grep client/node_modules | awk '{print $2}') + # Find any api, client, or server node processes local hanging_api_processes=$(ps aux | grep -v grep | grep api-server/node_modules | awk '{print $2}') + local hanging_client_processes=$(ps aux | grep -v grep | grep client/node_modules | awk '{print $2}') local hanging_server_processes=$(ps aux | grep -v grep | grep 'node production-start.js' | awk '{print $2}') - + # Send kill signal to the processes - if [ ${#hanging_api_processes} -gt "0" ]; then - kill -9 $hanging_api_processes &>/dev/null - fi - if [ ${#hanging_client_processes} -gt "0" ]; then - kill -9 $hanging_client_processes &>/dev/null - fi - if [ ${#hanging_server_processes} -gt "0" ]; then - kill -9 $hanging_server_processes &>/dev/null - fi - - kill -9 $gastby_pid $api_pid &>/dev/null + local processes=($hanging_api_processes $hanging_client_processes $hanging_server_processes) + + for pid in ${processes[@]}; do + if [ ${#pid} -gt "0" ]; then + kill -9 $pid &>/dev/null + fi + done + + kill -9 $gastby_pid $api_pid &>/dev/null + echo "Finally exiting with a status code of ${exit_code}" exit "${exit_code}" }