Skip to content

Commit b075fcf

Browse files
committed
Merge pull request nginx-proxy#260 from appropriate/test-trap-term
Trap TERM to allow quicker exit of web containers
2 parents f819a4e + 098b058 commit b075fcf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/test_helpers.bash

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,20 @@ function prepare_web_container {
108108
-w /var/www/ \
109109
$options \
110110
-e PYTHON_PORTS="$ports" \
111-
python:3 sh -c "
111+
python:3 bash -c "
112+
trap '[ \${#PIDS[@]} -gt 0 ] && kill -TERM \${PIDS[@]}' TERM
113+
declare -a PIDS
112114
for port in \$PYTHON_PORTS; do
113115
echo starting a web server listening on port \$port;
114116
mkdir /var/www/\$port
115117
cd /var/www/\$port
116118
echo \"answer from port \$port\" > data
117119
python -m http.server \$port &
120+
PIDS+=(\$!)
118121
done
119-
wait
122+
wait \${PIDS[@]}
123+
trap - TERM
124+
wait \${PIDS[@]}
120125
"
121126
assert_success
122127

0 commit comments

Comments
 (0)