...

Text file src/github.com/emissary-ingress/emissary/v3/docker/test-stats/entrypoint.sh

Documentation: github.com/emissary-ingress/emissary/v3/docker/test-stats

     1#!/bin/sh
     2
     3# Copyright 2018 Datawire. All rights reserved.
     4#
     5# Licensed under the Apache License, Version 2.0 (the "License");
     6# you may not use this file except in compliance with the License.
     7# You may obtain a copy of the License at
     8#
     9#     http://www.apache.org/licenses/LICENSE-2.0
    10#
    11# Unless required by applicable law or agreed to in writing, software
    12# distributed under the License is distributed on an "AS IS" BASIS,
    13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14# See the License for the specific language governing permissions and
    15# limitations under the License
    16
    17export LC_ALL=C.UTF-8
    18export LANG=C.UTF-8
    19
    20APPDIR=${APPDIR:-/application}
    21
    22env | grep V
    23echo "STATS-TEST: args $@"
    24
    25pids=""
    26
    27diediedie() {
    28    NAME=$1
    29    STATUS=$2
    30
    31    if [ $STATUS -eq 0 ]; then
    32        echo "STATS-TEST: $NAME claimed success, but exited \?\?\?\?"
    33    else
    34        echo "STATS-TEST: $NAME exited with status $STATUS"
    35    fi
    36
    37    ambassador_exit 1
    38}
    39
    40handle_chld() {
    41    trap - CHLD
    42    local tmp
    43    for entry in $pids; do
    44        local pid="${entry%:*}"
    45        local name="${entry#*:}"
    46        if [ ! -d "/proc/${pid}" ]; then
    47            wait "${pid}"
    48            STATUS=$?
    49            diediedie "${name}" "$STATUS"
    50        else
    51            tmp="${tmp:+${tmp} }${entry}"
    52        fi
    53    done
    54
    55    pids="$tmp"
    56    trap "handle_chld" CHLD
    57}
    58
    59handle_int() {
    60    echo "Exiting due to Control-C"
    61}
    62
    63# set -o monitor
    64trap "handle_chld" CHLD
    65trap "handle_int" INT
    66
    67ROOT=$$
    68
    69echo "STATS-TEST: starting stats-test service"
    70/usr/bin/python3 "$APPDIR/stats-test.py" "$@" &
    71TEST_PID=$!
    72pids="${pids:+${pids} }${TEST_PID}:stats-test"
    73
    74echo "STATS-TEST: starting stats-web service"
    75/usr/bin/python3 "$APPDIR/stats-web.py" &
    76WEB_PID=$!
    77pids="${pids:+${pids} }${WEB_PID}:stats-web"
    78
    79echo "STATS-TEST: waiting"
    80wait
    81

View as plain text