Last active
May 3, 2017 13:02
-
-
Save toolmantim/2d005f8e05d33be1e32fb3cd41c450f6 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: "$BUILDKITE_AGENT_META_DATA_QUEUE" |
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 | |
# 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