Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Last active May 3, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save toolmantim/2d005f8e05d33be1e32fb3cd41c450f6 to your computer and use it in GitHub Desktop.
Save toolmantim/2d005f8e05d33be1e32fb3cd41c450f6 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: "$BUILDKITE_AGENT_META_DATA_QUEUE"
#!/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
# 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
echo "Sleeping for 60..."
sleep 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment