From 76d8d2b88a288db4062c498271ec13e0dfe317a8 Mon Sep 17 00:00:00 2001 From: Anton Averchenkov <84287187+averche@users.noreply.github.com> Date: Fri, 17 Feb 2023 13:06:00 -0500 Subject: [PATCH] Stop vault on exit in gen_openapi.sh (#19252) --- changelog/19252.txt | 3 +++ scripts/gen_openapi.sh | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelog/19252.txt diff --git a/changelog/19252.txt b/changelog/19252.txt new file mode 100644 index 000000000..99121351d --- /dev/null +++ b/changelog/19252.txt @@ -0,0 +1,3 @@ +```release-note:improvement +openapi: Consistently stop Vault server on exit in gen_openapi.sh +``` diff --git a/scripts/gen_openapi.sh b/scripts/gen_openapi.sh index b92fb883b..e4cd34c4a 100755 --- a/scripts/gen_openapi.sh +++ b/scripts/gen_openapi.sh @@ -24,6 +24,14 @@ vault server -dev -dev-root-token-id=root & sleep 2 VAULT_PID=$! +defer_stop_vault() { + echo "Stopping Vault..." + kill $VAULT_PID + sleep 1 +} + +trap defer_stop_vault INT TERM EXIT + export VAULT_ADDR=http://127.0.0.1:8200 echo "Mounting all builtin plugins..." @@ -125,8 +133,6 @@ else 'http://127.0.0.1:8200/v1/sys/internal/specs/openapi' > openapi.json fi -kill $VAULT_PID -sleep 1 - echo echo "openapi.json generated" +echo