updated gce_when_preempted.sh

pull/2/head
Hari Sekhon 5 years ago
parent 9ba0e76b66
commit d27d237f7f

@ -17,17 +17,30 @@ set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
usage(){
echo "
cat <<EOF
Waits and watches GCE Metadata API for the preemption trigger before continuing to execute its arguments
Alternative to shutdown scripts or if you want to set up an interactive CLI latch on preemption
https://cloud.google.com/compute/docs/shutdownscript
usage:
Usage:
${0##*/} <commands>
"
${0##*/} "command1; command2; command 3" All commands execute in a subshell
${0##*/}; command 1; command2; command 3 All commands execute in current shell
(notice the semi-colon immediately after the script giving it no argument, merely using it as a latch mechanism)
${0##*/} command1; command2; command 3 First command executes in the subshell (it's an argument). Commands 2 & 3 execute in the current shell after this script
${0##*/} 'x=test; echo \$x' Variable is interpolated inside the single quotes at runtime after receiving Spot Termination notice
Inspired by whenup() / whendown() for hosts and whendone() for processes from interactive bash library .bash.d/* sourced as part of the .bashrc in this repo
For AWS there is a similar adjacent script aws_spot_when_terminated.sh
EOF
exit 3
}

Loading…
Cancel
Save