Last active
January 20, 2017 17:23
-
-
Save timmc/209a4aa5367636cd28163fddc6c8d0e4 to your computer and use it in GitHub Desktop.
bisect and lein template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd ./PATH/TO/PROJECT/BASE | |
export LEIN_FAST_TRAMPOLINE=true | |
lein clean | |
lein trampoline compile || { | |
echo "Build failed." | |
exit 125 | |
} | |
lein trampoline run & | |
until curl -sS http://localhost:12345/ALIVE_CHECK -m1 >/dev/null 2>&1; do | |
echo "starting" | |
sleep 5 | |
done | |
pid=$(lsof -i tcp:12345 -s tcp:listen -F p | tail --bytes=+2) | |
echo "PID: $pid" | |
response="$(curl -sS http://localhost:12345/ACTUAL_QUERY -m5 -i)" | |
(echo "$response" | grep 'EXPECTED_RESPONSE_STRING' >/dev/null) || { | |
echo "Unexpected response body" | |
echo "$response" | |
exit 125 | |
} | |
resp_header="$(echo "$response" | head -n1 | tr -d $'\r\n')" | |
while kill $pid 2>/dev/null; do | |
echo "stopping" | |
sleep 5 | |
done | |
echo "$resp_header" | |
case "$resp_header" in | |
$'HTTP/1.1 200 OK') | |
exit 0 | |
;; | |
$'HTTP/1.1 500 Server Error') | |
exit 1 | |
;; | |
*) | |
echo "Unexpected status code" | |
exit 125 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment