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:
@@ -29,8 +29,21 @@ if [ ! -f /output/index.html ]; then
|
||||
echo "[entrypoint] first run failed; cron will retry on schedule"
|
||||
fi
|
||||
|
||||
# Tee crontab into the place busybox expects (already done in image
|
||||
# via COPY) and run crond in foreground. -L /dev/stdout sends cron
|
||||
# stdout/stderr to docker logs.
|
||||
echo "[entrypoint] starting crond (fires per /etc/crontabs/root)"
|
||||
# Render the crontab from env so each per-user instance can fire on
|
||||
# its own schedule. Defaults match the original singleton (0800 / 2000
|
||||
# local). Two separate vars (AM / PM) instead of one combined string
|
||||
# so users can tweak one fire without re-deriving the other.
|
||||
CRON_AM="${DIGEST_CRON_AM:-0 8 * * *}"
|
||||
CRON_PM="${DIGEST_CRON_PM:-0 20 * * *}"
|
||||
mkdir -p /etc/crontabs
|
||||
{
|
||||
echo "# news-digest cron — generated at container start from env."
|
||||
echo "$CRON_AM /usr/local/bin/run-digest.sh"
|
||||
echo "$CRON_PM /usr/local/bin/run-digest.sh"
|
||||
} > /etc/crontabs/root
|
||||
echo "[entrypoint] crontab:"
|
||||
sed 's/^/ /' /etc/crontabs/root
|
||||
|
||||
# Foreground crond. -L /dev/stdout sends cron stdout/stderr to docker logs.
|
||||
echo "[entrypoint] starting crond"
|
||||
exec crond -f -L /dev/stdout -l 8
|
||||
|
||||
Reference in New Issue
Block a user