Merge pull request #260 from appropriate/test-trap-term
Trap TERM to allow quicker exit of web containers
This commit is contained in:
commit
b075fcf250
1 changed files with 7 additions and 2 deletions
|
@ -108,15 +108,20 @@ function prepare_web_container {
|
|||
-w /var/www/ \
|
||||
$options \
|
||||
-e PYTHON_PORTS="$ports" \
|
||||
python:3 sh -c "
|
||||
python:3 bash -c "
|
||||
trap '[ \${#PIDS[@]} -gt 0 ] && kill -TERM \${PIDS[@]}' TERM
|
||||
declare -a PIDS
|
||||
for port in \$PYTHON_PORTS; do
|
||||
echo starting a web server listening on port \$port;
|
||||
mkdir /var/www/\$port
|
||||
cd /var/www/\$port
|
||||
echo \"answer from port \$port\" > data
|
||||
python -m http.server \$port &
|
||||
PIDS+=(\$!)
|
||||
done
|
||||
wait
|
||||
wait \${PIDS[@]}
|
||||
trap - TERM
|
||||
wait \${PIDS[@]}
|
||||
"
|
||||
assert_success
|
||||
|
||||
|
|
Reference in a new issue