-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jobs on stopping/stopped should delay exit on global shutdown (#421)
- Loading branch information
Showing
5 changed files
with
71 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
consul: "consul:8500", | ||
logging: { | ||
level: "DEBUG", | ||
format: "text" | ||
}, | ||
jobs: [ | ||
{ | ||
name: "app", | ||
port: 8000, | ||
exec: "sleep 60", | ||
health: { | ||
exec: "true", | ||
interval: 1, | ||
ttl: 5, | ||
}, | ||
}, | ||
{ | ||
name: "preStop", | ||
exec: "echo 'preStop fired on app stopping'", | ||
when: { | ||
source: "app", | ||
once: "stopping" | ||
}, | ||
}, | ||
{ | ||
name: "postStop", | ||
exec: "echo 'postStop fired on app stopped'", | ||
when: { | ||
source: "app", | ||
once: "stopped" | ||
}, | ||
} | ||
] | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
#!/bin/bash | ||
|
||
docker-compose up -d consul app > /dev/null 2>&1 | ||
set -e | ||
|
||
function finish { | ||
local result=$? | ||
if [ $result -ne 0 ]; then | ||
echo '----- APP LOGS ------' | ||
docker logs "$APP_ID" | tee app.log | ||
echo '---------------------' | ||
fi | ||
exit $result | ||
} | ||
|
||
trap finish EXIT | ||
|
||
docker-compose up -d consul app | ||
|
||
# Wait for consul to elect a leader | ||
docker-compose run --no-deps test /go/bin/test_probe test_consul > /dev/null 2>&1 | ||
if [ ! $? -eq 0 ] ; then exit 1 ; fi | ||
docker-compose run --no-deps test /go/bin/test_probe test_consul | ||
|
||
APP_ID="$(docker-compose ps -q app)" | ||
docker-compose run --no-deps test /go/bin/test_probe test_sigterm "$APP_ID" > /dev/null 2>&1 | ||
result=$? | ||
|
||
CONSUL_ID="$(docker-compose ps -q consul)" | ||
TEST_ID=$(docker ps -l -f "ancestor=cpfix_test_probe" --format="{{.ID}}") | ||
|
||
if [ $result -ne 0 ]; then | ||
echo '----- TEST LOGS ------' | ||
docker logs "$TEST_ID" | tee test.log | ||
echo '----- APP LOGS ------' | ||
docker logs "$APP_ID" | tee app.log | ||
echo '----- CONSUL LOGS ------' | ||
docker logs "$CONSUL_ID" | tee consul.log | ||
echo '---------------------' | ||
fi | ||
exit $result | ||
docker-compose run --no-deps test /go/bin/test_probe test_sigterm "$APP_ID" | ||
|
||
# verify preStop fired | ||
docker logs "$APP_ID" | grep "msg=\"'preStop fired on app stopping" | ||
|
||
# # verify postStop fired | ||
docker logs "$APP_ID" | grep "msg=\"'postStop fired on app stopped" |
This file contains 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