Skip to content

Instantly share code, notes, and snippets.

@adkatrit
Last active August 23, 2017 14:57
Show Gist options
  • Save adkatrit/4536b6c03b904d0ad23889cb48b3df9b to your computer and use it in GitHub Desktop.
Save adkatrit/4536b6c03b904d0ad23889cb48b3df9b to your computer and use it in GitHub Desktop.
Genie Job Heartbeat
# requires jq, curl
# genie_job_status <HOST> <JOB_ID>
genie_job_status(){
GENIE_HOST=$1;
GENIE_JOB_ID=$2;
curl --silent "$GENIE_HOST/api/v3/jobs?size=100" | jq -rc '._embedded.jobSearchResultList[] | [.id,.status]' | grep $GENIE_JOB_ID;
}
# job_heartbeat <HOST> <JOB_ID> <BEEP INTERVAL IN SECONDS>
job_heartbeat(){
BEEP_INTERVAL=$3;
while true;
do genie_job_status $1 $2 | grep RUNNING && tput bel; sleep $BEEP_INTERVAL;
done;
}
# example:
# job_heartbeat http://genie.example:8080 50103a07-8f5d-4605-a80f-1baf07e7d7f9 2
# will beep every 2 seconds until job is not RUNNING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment