chore: add hourly INC ingest cron wrapper + schedule docs
run_ingest.sh loads .env and runs `import_tickets.py --from-bucket --apply`. Documented crontab: `15 7-19 * * *` in Africa/Nairobi (ingest at :15, 07:00–19:00). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
df054c92be
commit
4532643247
2 changed files with 41 additions and 2 deletions
16
README.md
16
README.md
|
|
@ -62,8 +62,20 @@ python import_tickets.py --inc-csv 2026-06-15T17-00-00.csv --apply
|
|||
```
|
||||
|
||||
Dry-run is the default (omit `--apply`). `import_tickets.py --from-bucket` shells out to
|
||||
the `aws` CLI using the `RUSTFS_*` env (no boto3 dependency). Hourly on the instance via
|
||||
cron `5 * * * *` (a few minutes after each export).
|
||||
the `aws` CLI using the `RUSTFS_*` env (no boto3 dependency).
|
||||
|
||||
## Schedule (cron)
|
||||
|
||||
On the instance, ingest at **:15 past every hour, 07:00–19:00 EAT** via
|
||||
[`run_ingest.sh`](run_ingest.sh) (loads `.env`, runs `--from-bucket --apply`):
|
||||
|
||||
```cron
|
||||
CRON_TZ=Africa/Nairobi
|
||||
15 7-19 * * * /opt/fleettickets/run_ingest.sh >> /var/log/fleettickets-inc.log 2>&1
|
||||
```
|
||||
|
||||
`CRON_TZ` matters — the export filenames and this schedule are in `Africa/Nairobi`.
|
||||
Skip-if-unchanged means a run on an already-ingested snapshot is a cheap no-op.
|
||||
|
||||
## Notes
|
||||
|
||||
|
|
|
|||
27
run_ingest.sh
Executable file
27
run_ingest.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
# run_ingest.sh — fleettickets · hourly INC ingest wrapper for cron.
|
||||
#
|
||||
# Loads env from the local .env (DATABASE_URL + RUSTFS_* + GEOCODER_*) and runs the
|
||||
# newest-INC-CSV ingest with --apply (skip-if-unchanged + archive are built in).
|
||||
#
|
||||
# Install on the instance (ingest at :15, 07:00–19:00 EAT):
|
||||
# 15 7-19 * * * /opt/fleettickets/run_ingest.sh >> /var/log/fleettickets-inc.log 2>&1
|
||||
# Ensure the crontab runs in the Africa/Nairobi timezone (CRON_TZ=Africa/Nairobi or
|
||||
# the host/container TZ), since the export filenames and the schedule are EAT.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Load .env if present (KEY=VALUE lines); never commit the real .env.
|
||||
if [ -f .env ]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1091
|
||||
. ./.env
|
||||
set +a
|
||||
fi
|
||||
|
||||
# Prefer the project venv if it exists, else the python on PATH (e.g. in-container).
|
||||
PY="python"
|
||||
[ -x ".venv/bin/python" ] && PY=".venv/bin/python"
|
||||
|
||||
exec "$PY" import_tickets.py --from-bucket --apply
|
||||
Loading…
Reference in a new issue