Skip to content

Commit

Permalink
fix: ensure right event dumping (#466)
Browse files Browse the repository at this point in the history
* fix: always ensure a newline

* fix: try dumping before and after sleep just in case
  • Loading branch information
DekusDenial authored Nov 9, 2023
1 parent e3d4ffb commit fcdaeeb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
# Trap these SIGNALs and run teardown
trap 'trap_handler $@' INT TERM

event_dumped=""
dump_event() {
if [ -r /tmp/sd_event.json ]; then
if [ -r /tmp/sd_event.json ] && [ -z "$event_dumped" ]; then
echo
cat /tmp/sd_event.json
event_dumped=1
fi
}

trap_handler() {
code=$?
if [ $code -ne 0 ]; then
echo "Exit code:$code received in run.sh, waiting for $SD_TERMINATION_GRACE_PERIOD_SECONDS seconds"
dump_event
# this trap does not wait for launcher SIGTERM processing completion
# so add sleep until timeoutgraceperiodseconds is elapsed
sleep $((SD_TERMINATION_GRACE_PERIOD_SECONDS - 1))
Expand Down

0 comments on commit fcdaeeb

Please sign in to comment.