diff --git a/app/icon.tsx b/app/icon.tsx deleted file mode 100644 index f856daf..0000000 --- a/app/icon.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { ImageResponse } from "next/og"; - -export const size = { width: 32, height: 32 }; -export const contentType = "image/png"; - -export default function Icon() { - return new ImageResponse( - ( -
- {/* Ground line */} -
- {/* Lift hill — semicircle bump */} -
- {/* Vertical loop — circle outline */} -
-
- ), - { width: 32, height: 32 }, - ); -} diff --git a/docker-compose.yml b/docker-compose.yml index 6d4eb35..836b014 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,5 +9,15 @@ services: - NODE_ENV=production restart: unless-stopped + scraper: + image: gitea.thewrightserver.net/josh/sixflagssupercalendar:latest + volumes: + - park_data:/app/data + environment: + - NODE_ENV=production + - TZ=America/New_York # set your local timezone so "3am" is 3am your time + command: sh /app/scripts/scrape-schedule.sh + restart: unless-stopped + volumes: park_data: diff --git a/lib/db.ts b/lib/db.ts index 813ae3f..461513d 100644 --- a/lib/db.ts +++ b/lib/db.ts @@ -167,7 +167,7 @@ export function getMonthCalendar( return result; } -const STALE_AFTER_MS = 7 * 24 * 60 * 60 * 1000; // 1 week +const STALE_AFTER_MS = 72 * 60 * 60 * 1000; // 72 hours /** * Returns true when the scraper should skip this park+month. diff --git a/public/logo.svg b/public/logo.svg deleted file mode 100644 index 186147d..0000000 --- a/public/logo.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/scripts/scrape-schedule.sh b/scripts/scrape-schedule.sh new file mode 100644 index 0000000..9c91ea0 --- /dev/null +++ b/scripts/scrape-schedule.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Nightly scraper scheduler — runs inside the Docker scraper service. +# +# Behaviour: +# 1. Runs an initial scrape immediately on container start. +# 2. Sleeps until 3:00 AM (container timezone, set via TZ env var). +# 3. Runs the scraper, then sleeps until the next 3:00 AM, forever. +# +# Timezone: set TZ in the scraper service environment to control when +# "3am" is (e.g. TZ=America/New_York). Defaults to UTC if unset. + +log() { + echo "[scheduler] $(date '+%Y-%m-%d %H:%M %Z') — $*" +} + +run_scrape() { + log "Starting scrape" + if npm run scrape; then + log "Scrape completed" + else + log "Scrape failed — will retry at next scheduled time" + fi +} + +seconds_until_3am() { + now=$(date +%s) + # Try today's 3am first; if already past, use tomorrow's. + target=$(date -d "today 03:00" +%s) + if [ "$now" -ge "$target" ]; then + target=$(date -d "tomorrow 03:00" +%s) + fi + echo $((target - now)) +} + +# ── Run immediately on startup ──────────────────────────────────────────────── +run_scrape + +# ── Nightly loop ────────────────────────────────────────────────────────────── +while true; do + wait=$(seconds_until_3am) + next=$(date -d "now + ${wait} seconds" '+%Y-%m-%d %H:%M %Z') + log "Next scrape in $((wait / 3600))h $((( wait % 3600) / 60))m (${next})" + sleep "$wait" + run_scrape +done