diff options
author | David Timber <dxdt@dev.snart.me> | 2024-11-11 23:43:40 +0100 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2024-11-12 00:42:30 +0100 |
commit | b52bb37f1446b8feb3934d1207da21ffd4fd637c (patch) | |
tree | 0399a4f64c620fcd7180d4cbfd252b73c4c57994 /viewcount-tothemoooon/vc-thm |
To the moooooon!
Diffstat (limited to 'viewcount-tothemoooon/vc-thm')
-rwxr-xr-x | viewcount-tothemoooon/vc-thm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/viewcount-tothemoooon/vc-thm b/viewcount-tothemoooon/vc-thm new file mode 100755 index 0000000..d285edf --- /dev/null +++ b/viewcount-tothemoooon/vc-thm @@ -0,0 +1,40 @@ +#!/bin/bash +declare -r ARGV0='vc-thm' + +pull_url () { + local i=0 + + echo -n "$ARGV0: " >&2 + while true + do + sleep 0.5 & # limit rate to one per 500 ms + + curl -sSL "$1" > /dev/null + wait + + let 'i += 1' + echo -n "$i " >&2 + done +} + +if [ -z "$1" ]; then + echo "Usage: $ARGV0 <URL> [TIMEOUT]" >& 2 + exit 2 +fi + +# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule +# > The shortest interval you can run scheduled workflows is once every 5 minutes. +[ -z "$2" ] && TIMEOUT=270 || TIMEOUT="$2" + + +set -e +pull_url "$1" & +CHILD="$!" +sleep "$TIMEOUT" +set +e + +kill -TERM "$CHILD" +wait +echo >&2 + +exit 0 # don't care about the exit code from pull_url |