#!/usr/bin/env bash

set -uo pipefail

interval=${POLL_INTERVAL:-5}

# To allow easy Ctrl-C of this, trap SIGINT as well
# as run the python portion asynchronously so that Bash
# will receive the signal.
trap exit SIGINT

while true; do
    echo "Polling every $interval seconds..."
    /src/pipedream/slurm/pipedream_slurm &
    wait $!
    if [ $? -ne 0 ]; then
        echo "Failed to update data!"
    fi

    sleep $interval;
done
