-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwait_for_miq.sh
executable file
·56 lines (44 loc) · 964 Bytes
/
wait_for_miq.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e
PREVPWD="`dirname $0`"
source $PREVPWD/colors.sh
function clean_up {
printRed "Error"
exit
}
function die_error {
set +u
printRed "Error: $1"
exit
}
trap clean_up SIGHUP SIGINT SIGTERM ERR
echo "Restarting evm..."
if [ "$1" == "db" ]; then
printRed "RESETTING DB!!"
sudo killall ruby &> /dev/null || true
bundle exec bin/rake evm:kill || die_error 'bundle exec bin/rake evm:kill failed'
sleep 3
bundle exec bin/rake evm:db:reset || die_error 'bundle exec bin/rake evm:db:reset failed'
bundle exec bin/rake evm:start
else
bundle exec bin/rake evm:kill evm:start
fi
echo Waiting for miq
DIFF=0
START=$(date +%s.%N)
until curl 127.0.0.1:3000 &>/dev/null; do
sleep 3
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
printYellow "Waiting... $DIFF"
done
echo -e "\a"
sleep 0.1
echo -e "\a"
echo -e "\a"
sleep 0.1
echo -e "\a"
sleep 0.1
echo -e "\a"
sleep 0.1
printBlue "Done. Waited $DIFF years for miq."