-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper.sh
More file actions
44 lines (34 loc) · 826 Bytes
/
wrapper.sh
File metadata and controls
44 lines (34 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
kill_services()
{
if [ "$SERVER_PID" ] && [ "$GATEWAY_PID" ]; then
kill -TERM $SERVER_PID $GATEWAY_PID 2>/dev/null
else
KILL_SERVICES_ONCE_STARTED="yes"
fi
}
trap 'kill_services' TERM INT
java -javaagent:aws-opentelemetry-agent.jar $JAVA_OPTS -jar app.jar & SERVER_PID=$!
./grpc-gateway & GATEWAY_PID=$!
if [ "$KILL_SERVICES_ONCE_STARTED" ]; then
kill_services
fi
while true; do
if kill -0 $SERVER_PID $GATEWAY_PID 2>/dev/null; then
sleep 1s
else
kill_services
break
fi
done
wait $SERVER_PID
SERVER_EXIT_CODE=$?
wait $GATEWAY_PID
GATEWAY_EXIT_CODE=$?
echo Server exit code: $SERVER_EXIT_CODE
echo Gateway exit code: $GATEWAY_EXIT_CODE
if [ $SERVER_EXIT_CODE -gt 0 ]; then
exit $SERVER_EXIT_CODE
else
exit $GATEWAY_EXIT_CODE
fi