aboutsummaryrefslogtreecommitdiff
path: root/viewcount-tothemoooon
diff options
context:
space:
mode:
Diffstat (limited to 'viewcount-tothemoooon')
-rwxr-xr-xviewcount-tothemoooon/vc-thm40
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