news-digest: per-instance cron schedule via env

Hardcoded crontab → render at container start from
DIGEST_CRON_AM + DIGEST_CRON_PM. Defaults match the original
0800 / 2000 so existing deploys are no-ops.

scripts/add-digest-user.sh learns --am and --pm flags so each
teammate's stack can fire on their hours:

  scripts/add-digest-user.sh bob --am "0 6 * * *" --pm "0 17 * * *"
  scripts/add-digest-user.sh carol --pm "30 18 * * 1-5"   # weekdays only

Standard 5-field cron syntax; busybox crond honors the container's
\$TZ. Removed the now-unused stacks/news-digest/crontab file and
the matching COPY in the Dockerfile.
This commit is contained in:
vh
2026-04-28 14:29:55 -07:00
parent aeb5c18ca3
commit d552e289cb
6 changed files with 75 additions and 12 deletions
+44 -3
View File
@@ -23,8 +23,46 @@
set -euo pipefail
USER_ARG="${1:?usage: $0 <username> [password]}"
USER_PASS="${2:-}"
usage() {
cat <<EOF
usage: $0 <username> [password] [--am "MIN HR * * *"] [--pm "MIN HR * * *"]
Defaults: AM = "0 8 * * *", PM = "0 20 * * *". Cron syntax is
standard 5-field; busybox crond honors the container's \$TZ.
Examples:
$0 alice
$0 bob --am "0 6 * * *" --pm "0 17 * * *"
$0 carol s3cret --pm "30 18 * * 1-5" # weekdays only PM run
EOF
exit 1
}
USER_ARG=""
USER_PASS=""
CRON_AM="0 8 * * *"
CRON_PM="0 20 * * *"
while [ "$#" -gt 0 ]; do
case "$1" in
--am) CRON_AM="$2"; shift 2 ;;
--pm) CRON_PM="$2"; shift 2 ;;
--help|-h) usage ;;
--*) echo "unknown flag: $1" >&2; usage ;;
*)
if [ -z "$USER_ARG" ]; then
USER_ARG="$1"
elif [ -z "$USER_PASS" ]; then
USER_PASS="$1"
else
echo "unexpected positional arg: $1" >&2; usage
fi
shift
;;
esac
done
[ -n "$USER_ARG" ] || usage
HOST=ana-docker
WORKSTATION_STACK="$(dirname "$0")/../stacks/news-digest"
PROJECT="digest-$USER_ARG"
@@ -102,7 +140,7 @@ scp -q "$WORKSTATION_STACK/compose.yaml" "$HOST:$HOST_COMPOSE_DIR/compose.yaml"
# Also need the build context (Dockerfile, *.py, templates/) so the
# image can build if it's not already cached. Use the existing tree.
scp -q "$WORKSTATION_STACK/Dockerfile" "$HOST:$HOST_COMPOSE_DIR/Dockerfile"
scp -q "$WORKSTATION_STACK"/{digest.py,seed-headlines.py,web.py,entrypoint.sh,run-digest.sh,crontab} "$HOST:$HOST_COMPOSE_DIR/"
scp -q "$WORKSTATION_STACK"/{digest.py,seed-headlines.py,web.py,entrypoint.sh,run-digest.sh} "$HOST:$HOST_COMPOSE_DIR/"
ssh "$HOST" "mkdir -p $HOST_COMPOSE_DIR/templates"
scp -q "$WORKSTATION_STACK"/templates/* "$HOST:$HOST_COMPOSE_DIR/templates/"
@@ -139,6 +177,8 @@ DIGEST_MINIFLUX_WORLD_CATEGORY=World
DIGEST_MINIFLUX_LOCAL_CATEGORY=Local
DIGEST_MINIFLUX_HEADLINES_HOURS=8
DIGEST_MINIFLUX_HEADLINES_MAX=15
DIGEST_CRON_AM=$CRON_AM
DIGEST_CRON_PM=$CRON_PM
NEWS_DIGEST_OUTPUT_DIR=$HOST_DATA_DIR
EOF
@@ -166,6 +206,7 @@ bold "✓ provisioned digest for $USER_ARG"
echo
echo " digest URL : http://10.250.50.70:$new_port/"
echo " miniflux UI : http://10.250.50.70:8080/ (login: $USER_ARG / $USER_PASS)"
echo " schedule : AM '$CRON_AM' / PM '$CRON_PM' (TZ from \$NEWS_DIGEST_TZ)"
echo " compose dir : $HOST:$HOST_COMPOSE_DIR/"
echo " output dir : $HOST:$HOST_DATA_DIR/"
echo