Skip to content

Instantly share code, notes, and snippets.

@lox
Forked from toolmantim/pipeline.yml
Last active May 4, 2017 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lox/335e061cbd4fd8284b89a3af62c958f5 to your computer and use it in GitHub Desktop.
Save lox/335e061cbd4fd8284b89a3af62c958f5 to your computer and use it in GitHub Desktop.
Testing agent signal handling
steps:
# - name: Test 1
# command: test-1.sh
# agents:
# queue: "$BUILDKITE_AGENT_META_DATA_QUEUE"
# - name: Test 2
# command: test-2.sh
# agents:
# queue: "$BUILDKITE_AGENT_META_DATA_QUEUE"
- name: Test 3
command: test-3.sh
agents:
queue: "lox-dev"
#!/bin/bash
# Blocks using read, and prints in the signal handlers
handle_int() {
echo "Received INT.";
echo "Finished.";
exit 0
}
handle_term() {
echo "Received TERM.";
echo "Finished.";
exit 0
}
trap handle_int INT
trap handle_term TERM
echo "Reading..."
read -r
#!/bin/bash
# Blocks using read, and sleeps in the signal handlers
handle_int() {
echo "Received INT. Sleeping for 5...";
sleep 5;
echo "Finished.";
exit 0
}
handle_term() {
echo "Received TERM. Sleeping for 5...";
sleep 5;
echo "Finished.";
exit 0
}
trap handle_int INT
trap handle_term TERM
echo "Reading..."
read -r
#!/bin/bash
if [ -z "${PS1-}" ] ; then
echo non-interactive
else
echo interactive
fi
# Blocks using sleep, and sleeps in the signal handlers
handle_int() {
echo "Received INT. Sleeping for 5...";
sleep 5;
echo "Finished.";
exit 0
}
handle_term() {
echo "Received TERM. Sleeping for 5...";
sleep 5;
echo "Finished.";
exit 0
}
trap handle_int INT
trap handle_term TERM
trap 'echo "doing some cleaning"' EXIT
echo "Sleeping for 600..."
sleep 600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment