-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrepro.sh
executable file
·80 lines (67 loc) · 1.7 KB
/
repro.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
set -e
main() {
installGeth
runGethnet
printf -- "\033[34mStarting main.go...\033[0m\n"
buildAndRunSubscriber
sleep 2
printf -- "\033[34mmain.go is running.\033[0m\n"
printps
printf -- "\033[34mSleeping for 5...\033[0m\n"
sleep 5
printf -- "\033[34mSimultaneously kill all child processes. Check ps afterwards..\033[0m\n"
}
exit_handler() {
# Clear all signal handlers to prevent handler loop
trap - 1 2 3 15
# Kill all child subprocesses
kill -- -$$ || true # Unsubscription won't end
}
trap "exit_handler" EXIT SIGTERM SIGINT
buildAndRunSubscriber() {
DIR=`mktemp -d`
go build -o "${DIR}/blockingbuild" main.go
${DIR}/blockingbuild &
}
installGeth() {
printf -- "\033[34mInstalling geth 1.8.27...\033[0m\n"
ethpkg=github.com/ethereum/go-ethereum
ethpath=$GOPATH/src/$ethpkg
if [ -d "$ethpath" ]; then
pushd "$ethpath" >/dev/null
git checkout master &>/dev/null
go get -d -u $ethpkg
else
go get -d $ethpkg
pushd "$ethpath" >/dev/null
fi
git checkout v1.8.27 2>/dev/null
popd >/dev/null
go install $ethpkg/cmd/geth
}
waitForResponse ()
{
printf -- "\033[34mWaiting for $1.\033[0m\n"
sleepCount=0
while [ "$sleepCount" -le "300" ] && ! curl -s "$1" >/dev/null; do
sleep 1
sleepCount=$((sleepCount+1))
done
if [ "$sleepCount" -gt "300" ]; then
printf -- "\033[31mTimed out waiting for $1 (waited 300s).\033[0m\n"
exit 1
fi
printf -- "\033[34mService on $1 is ready.\033[0m\n"
}
runGethnet() {
printf -- "\033[34mStarting geth...\033[0m\n"
./gethnet &
waitForResponse http://127.0.0.1:18545
printf -- "\033[34mGeth is running.\033[0m\n"
}
printps() {
printf -- "\033[34mProcesses...\033[0m\n"
ps
}
main