-
-
Save lox/335e061cbd4fd8284b89a3af62c958f5 to your computer and use it in GitHub Desktop.
Testing agent signal handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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