Skip to content

Commit

Permalink
Simplify api init script
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed May 4, 2022
1 parent f2d3d8b commit 95bf915
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions docker/api-init.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash

pid=0

# SIGTERM-handler
termination_handler() {
exit_status=0
if [ $pid -ne 0 ]; then
echo 'SIGTERM was received, stopping the API'
curl --silent --fail --request POST \
Expand All @@ -11,14 +14,12 @@ termination_handler() {
--data '{"jsonrpc": "2.0" ,"method": "shutdown"}' \
http://localhost:"${STARGATE__PORT}"/operations/application-control
wait "$pid"
exit_status=$?
fi
exit 143; # 128 + 15 -- SIGTERM
exit "$exit_status"
}
trap 'kill ${!}; termination_handler' SIGTERM

trap 'termination_handler' SIGTERM
./api-start.sh &
pid="$!"
# wait forever
while true
do
tail -f /dev/null & wait ${!}
done
wait "$pid"

0 comments on commit 95bf915

Please sign in to comment.