Hello community!
I am trying to find out how can I see the stdout or stderr from a bash script. I created a bash script, and I ran it in the following way:
- run:
name: Backend server health check
command: sh ./backend_server_health_check.sh << parameters.backend_domain >> << parameters.backend_api_key >>
My script looks like:
start=$(date +%s)
end=$(date +%s)
working_time=$((end-start))
seconds_for_waiting=5
max_retry_time_seconds=30
server_domain=$1
api_key=$2
health_check_url="api/0.1/version"
while [ $working_time -lt $max_retry_time_seconds ];
do
sleep $seconds_for_waiting
end=$(date +%s)
working_time=$((end-start))
response_code=$(
curl -s -o /dev/null -w "%{response_code}" -H "Authorization: $api_key"\
--url https://$server_domain/$healt_check_url
)
if [ $response_code -eq 200 ]; then
echo "\nSERVER: $server_domain is up and running...\n"
exit 0
fi
echo "\nRequest to: https://$1 FAILED: We continue working after $working_time seconds..."
echo "Status code response: $response_code"
done
echo "\n[ERROR] After $(($end-$start)) seconds the server is still unavailable ...\n"
exit 1
First of all, I would like to see the each echo
it executes, but after finish it should send a signal to the CircleCI step, instead of that, it is running forever.
Could you give me some advice? Thank so much!