Skip to content

Commit

Permalink
Handle SIGTERM in empty docker-compose container
Browse files Browse the repository at this point in the history
In docker-compose-1-empty.yml nc was being invoked directly which led
to SIGTERM being ignored by the container. This added an unneccessary
10 second wait after tests that used it while docker timed out and
sends a SIGKILL. This fixes that by forking nc and trapping SIGTERM
and directly killing nc.

Change-Id: Ifc5072b33c45f9fa90868a87ca69982c051e10e1
Signed-off-by: Julian Carrivick <cjulian@au1.ibm.com>
  • Loading branch information
juliancarrivick-ibm committed Sep 7, 2016
1 parent dc2d339 commit ffbe4d1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bddtests/docker-compose-1-empty.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
empty:
image: hyperledger/fabric-src
# TCP Listen on a port to satisfy the container 'ready' condition
command: nc -k -l 50000
# If we don't fork, trap and wait, nc (and by extension, the container)
# won't respond to the SIGTERM that docker sends when it wants to stop.
command: |
sh -c '
nc -k -l 50000 &
pid=$$!
trap "kill $$pid; exit 0" TERM
wait $$pid
'

0 comments on commit ffbe4d1

Please sign in to comment.