Skip to content
This repository was archived by the owner on Nov 21, 2022. It is now read-only.

Commit 86a6a65

Browse files
author
Archit Sharma
committed
add host status check in cmdline tool vizit
1 parent 3a7885f commit 86a6a65

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

vizit

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/bash
22

3+
# Path to sarjitsu.conf
34
APP_CONF=conf/sarjitsu.conf
45

6+
# From 'curl' man pages:
7+
# "Maximum time in seconds that you allow curl's connection to take.
8+
# This only limits the connection phase, so if curl connects within
9+
# the given period it will continue - if not it will exit."
10+
TIMEOUT=10
11+
512
log(){
613
echo -e "[$(date +'%D %H:%M:%S %Z')] - $*"
714
}
@@ -56,7 +63,24 @@ upload_em_all(){
5663
CMD+=" -F datafile=@$line"
5764
done < <(echo "$*")
5865
log "attempting to upload file(s) to $APP_URL now.."
59-
OUTPUT=$(curl -s $CMD -F 'check_all=check_all' -F 'cmd_mode=True' $APP_URL)
66+
log "Current connection TIMEOUT value: $TIMEOUT seconds.."
67+
68+
OUTPUT=$(curl --connect-timeout $TIMEOUT -s $CMD -F 'check_all=check_all' -F 'cmd_mode=True' $APP_URL)
69+
70+
if [[ -z $OUTPUT ]]; then
71+
CHECK_HOST=$(ping -c 1 $BACKEND_HOST | grep "1 received")
72+
if [[ -z $CHECK_HOST ]]; then
73+
log "$APP_URL is down."
74+
log "Check status of your BACKEND_HOST endpoint in conf/sarjitsu.conf"
75+
exit 1
76+
else
77+
log "$APP_URL is up and running, but for some reason, connection timed out. Try again?"
78+
exit -1
79+
fi
80+
else
81+
log "Files uploaded successfully.."
82+
fi
83+
6084
echo $OUTPUT | ./utils/vizit_results_parser.py
6185
}
6286

0 commit comments

Comments
 (0)