From c6de8484393c0602ccbe560be7c058d828bea228 Mon Sep 17 00:00:00 2001 From: Tim Lucas Date: Tue, 26 Jul 2016 09:32:07 +1000 Subject: [PATCH] Send all the kills before waiting --- .../scripts/buildkite-agent-lifecycled-handler | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packer/conf/buildkite-agent/scripts/buildkite-agent-lifecycled-handler b/packer/conf/buildkite-agent/scripts/buildkite-agent-lifecycled-handler index 39d633804..488c8addc 100755 --- a/packer/conf/buildkite-agent/scripts/buildkite-agent-lifecycled-handler +++ b/packer/conf/buildkite-agent/scripts/buildkite-agent-lifecycled-handler @@ -9,12 +9,12 @@ echo "Stopping buildkite-agent gracefully" for i in $(seq 1 "${BUILDKITE_AGENTS_PER_INSTANCE}"); do service "buildkite-agent-${i}" stop & +done - # Need to ensure it's the buildkite-agent user, so it doesn't match this lifecycld handler script - while pgrep -u buildkite-agent buildkite-agent > /dev/null; do - echo "Waiting for service buildkite-agent-${i} to have stopped..." - sleep 5 - done +# Need to ensure it's the buildkite-agent user, so it doesn't match this lifecycld handler script +while pgrep -u buildkite-agent buildkite-agent > /dev/null; do + echo "Waiting for all buildkite-agent processes to have stopped..." + sleep 5 done -echo "buildkite-agent stopped" +echo "All buildkite-agent processes have stopped"