Skip to content

Commit

Permalink
Merge pull request #2602 from IntersectMBO/better_cleanup_on_interrupt
Browse files Browse the repository at this point in the history
feat: add cleanup function and trap for SIGINT
  • Loading branch information
mkoura committed Sep 5, 2024
2 parents ec40455 + ed1ea53 commit 788ab39
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions .github/regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ fi
# shellcheck disable=SC1090,SC1091
. .github/nix_override_cardano_node.sh

_cleanup() {
# stop all running cluster instances
stop_instances "$WORKDIR"

# stop postgres if running
stop_postgres || true
}

# cleanup on Ctrl+C
trap 'set +e; _cleanup; exit 130' SIGINT

echo "::group::Nix env setup"
printf "start: %(%H:%M:%S)T\n" -1

Expand Down Expand Up @@ -183,11 +194,7 @@ if [ "${KEEP_CLUSTERS_RUNNING:-""}" = 1 ]; then
set -"$sets"
fi

# stop all running cluster instances
stop_instances "$WORKDIR"

# stop postgres if running
stop_postgres || true
_cleanup

# prepare artifacts for upload in Github Actions
if [ -n "${GITHUB_ACTIONS:-""}" ]; then
Expand Down

0 comments on commit 788ab39

Please sign in to comment.