Skip to content

Commit ffbe4d1

Browse files
Handle SIGTERM in empty docker-compose container
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 <[email protected]>
1 parent dc2d339 commit ffbe4d1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bddtests/docker-compose-1-empty.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
empty:
22
image: hyperledger/fabric-src
33
# TCP Listen on a port to satisfy the container 'ready' condition
4-
command: nc -k -l 50000
4+
# If we don't fork, trap and wait, nc (and by extension, the container)
5+
# won't respond to the SIGTERM that docker sends when it wants to stop.
6+
command: |
7+
sh -c '
8+
nc -k -l 50000 &
9+
pid=$$!
10+
trap "kill $$pid; exit 0" TERM
11+
wait $$pid
12+
'

0 commit comments

Comments
 (0)