Skip to content

Commit

Permalink
fix(ecs): terminate Artillery CLI on SIGTERM
Browse files Browse the repository at this point in the history
- Replace the use of "wait" with "tail --pid". The wait command can't
  be used because the Artillery CLI runs in a subshell
- If Artillery CLI does not exist after the timeout, kill it with
  SIGKILL
  • Loading branch information
hassy committed Jun 10, 2024
1 parent 8dc8f1a commit 199c0d6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/artillery/lib/platform/aws-ecs/worker/loadgen-worker
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,19 @@ cleanup () {
if [[ $CLI_RUNNING = "yes" ]] ; then
printf "Interrupted with %s, stopping\n" "$sig"
EXIT_CODE=$ERR_INTERRUPTED
kill -TERM $CLI_PID # TODO: Check handling in A9 CLI
wait $CLI_PID
CLI_STATUS=$(cat exitCode) # TODO: Could be 0, but is not a successful run
kill -TERM $CLI_PID
set +e
timeout 20 tail --pid $CLI_PID -f /dev/null
if [[ $? -eq 124 ]] ; then
# timeout exits with 124 if the process it's waiting on is still running
# i.e. if tail is still running it means the Artillery CLI did not exit:
kill -KILL $CLI_PID
CLI_STATUS=143 # SIGTERM (128 + 15)
else
# Preserve the exit code of the CLI
CLI_STATUS=$(cat exitCode)
fi
set -e
CLI_RUNNING="no"
fi

Expand Down

0 comments on commit 199c0d6

Please sign in to comment.