Skip to content

Commit

Permalink
fix(dgoss): edgecase where no log is written (#997)
Browse files Browse the repository at this point in the history
* fix(dgoss): edgecase borderline case where no log is written

* add force stop

* refactor wait for logs
  • Loading branch information
dklimpel authored Nov 21, 2024
1 parent 43c4e0c commit 817cbb6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion extras/dgoss/dgoss
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ error() {

cleanup() {
set +e
# There is a chance that the log will not be written completely.
# Exit the container and retrieve the last line of logs to ensure
# that all logs have been read.
info "Stopping container"
$CONTAINER_RUNTIME stop --time 1 "$id" > /dev/null 2>&1
$CONTAINER_RUNTIME logs --tail 1 "$id" > /dev/null 2>&1

{ kill "$log_pid" && wait "$log_pid"; } 2> /dev/null
if [ -n "$CONTAINER_LOG_OUTPUT" ]; then
info "Copying log"
cp "$tmp_dir/docker_output.log" "$CONTAINER_LOG_OUTPUT"
fi
[ "$DEBUG" ] || rm -rf "$tmp_dir"
if [[ $id ]];then
if [[ $id ]]; then
info "Deleting container"
$CONTAINER_RUNTIME rm -vf "$id" > /dev/null
fi
Expand Down

0 comments on commit 817cbb6

Please sign in to comment.