...
1#!/bin/bash
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 "DEMO: args $@"
24
25pids=()
26
27handle_chld() {
28 local tmp=()
29
30 for (( i=0; i<${#pids[@]}; ++i )); do
31 split=(${pids[$i]//;/ }) # the space after the trailing / is critical!
32 pid=${split[0]}
33 name=${split[1]}
34
35 if [ ! -d /proc/$pid ]; then
36 wait $pid
37 echo "DEMO: $name exited: $?"
38 echo "DEMO: shutting down"
39 exit 1
40 else
41 tmp+=(${pids[i]})
42 fi
43 done
44
45 pids=(${tmp[@]})
46}
47
48set -o monitor
49trap "handle_chld" CHLD
50
51ROOT=$$
52
53echo "SHADOW: starting shadow service"
54/opt/venv/bin/python3 "$APPDIR/shadow.py" "$@" &
55pids+=("$!;shadow")
56
57echo "SHADOW: waiting"
58wait
59
View as plain text