1#!/bin/bash 2# Copyright 2021 gRPC authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16 17# This script is being launched from the run_xds_tests.py runner and is 18# responsible for managing child PHP processes. 19 20cleanup () { 21 echo "Trapped SIGTERM. Cleaning up..." 22 set -x 23 kill -9 $PID1 24 kill -9 $PID2 25 running=false 26 set +x 27} 28 29trap cleanup SIGTERM 30 31set -e 32cd $(dirname $0)/../../.. 33root=$(pwd) 34 35# tmp_file1 contains the list of RPCs (and their spec) the parent PHP 36# process want executed 37tmp_file1=$(mktemp) 38# tmp_file2 contains the RPC result of each key initiated 39tmp_file2=$(mktemp) 40 41set -x 42# This is the PHP parent process, who is primarily responding to the 43# run_xds_tests.py runner's stats requests 44php -d extension=grpc.so -d extension=pthreads.so \ 45 src/php/tests/interop/xds_client.php $1 $2 $3 $4 $5 $6 \ 46 --tmp_file1=$tmp_file1 --tmp_file2=$tmp_file2 & 47PID1=$! 48 49# This script watches RPCs written to tmp_file1, spawn off more PHP 50# child processes to execute them, and writes the result to tmp_file2 51python3 -u src/php/bin/xds_manager.py \ 52 --tmp_file1=$tmp_file1 --tmp_file2=$tmp_file2 \ 53 --bootstrap_path=$GRPC_XDS_BOOTSTRAP & 54PID2=$! 55set +x 56 57# This will be killed by a SIGTERM signal from the run_xds_tests.py 58# runner 59running=true 60while $running 61do 62 sleep 1 63done 64