Skip to content

Commit

Permalink
Fix looping issue with healthchecks.io
Browse files Browse the repository at this point in the history
  • Loading branch information
itsamenathan committed Dec 7, 2023
1 parent 29f1331 commit 0085488
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ output_file="${OUTPUTFILE:-/data/xmlguide.xmltv}"
output_dir="$(dirname "$output_file")"
date_format="%Y-%m-%d %H:%M:%S %Z"

# Ping a healthcheck.io endpoint
healthcheck_io() {
# Ping a healthchecks.io endpoint
healthchecks_io() {
[ "$1" ] && local url_path="/${1}" || local url_path=""
if [ "$HEALTHCHECK_URL" ]; then
curl -fsS -m 10 --retry 5 -o /dev/null "$HEALTHCHECK_URL$url_path"
Expand All @@ -29,6 +29,9 @@ validate() {
}

zap2it() {
# Ping healthchecks.io/start
healthchecks_io "start"

echo "Started: $(date +"$date_format")"

# Run script
Expand All @@ -41,29 +44,33 @@ zap2it() {

# remove historical files
rm "$output_dir"/xmlguide.2*.xmltv

# Ping healthchecks.io
healthchecks_io
}

main() {
# Validate input
validate

# Loop if sleeptime is defined
if [ "$SLEEPTIME" ]; then
while true; do
echo "Running zap2it"

zap2it

echo "Next: $(date +"$date_format" -d "+$SLEEPTIME seconds")"

# sleep until next run
sleep "$SLEEPTIME"

done
else
echo "Running zap2it"
zap2it
fi

}

# Run the scripts functions
healthcheck_io "start"
validate
main
healthcheck_io

0 comments on commit 0085488

Please sign in to comment.