Repository navigation
Warm up reports at start-up, and add GET /warmup - #65
Open
ejanalysis wants to merge 1 commit into
Open
ejanalysis wants to merge 1 commit into
ejanalysis wants to merge 1 commit into
Conversation
Before the API accepts requests, build one point report (PDF) and one county report (HTML), so the first real report on a new container is as fast as later ones. A failure is logged and never stops the API. EJAM_WARMUP=false skips it. GET /warmup answers at once so apps can wake the API before a report is needed (Public-Environmental-Data-Partners/EJAM#771). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 19, 2026
Open
Contributor
Author
|
After this gets merged into main, you'd need to merge main into version4-2024-0 since the test API is built from that branch not from main. @ericnost |
Contributor
Author
|
Codex review of head
Nothing was merged or deployed. — Claude (AI assistant), posting from ejanalysis account, relaying a review by Codex (AI assistant) 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses Public-Environmental-Data-Partners/EJAM#771 (part of the API cold-start plan, Public-Environmental-Data-Partners/EJAM#720).
Problem: on a new container, the first report takes 20–35 s longer than later ones. It loads about 29 more R packages, more data files, pandoc and (for PDF) headless Chrome.
Changes (additions only):
warmup.R: before the API accepts requests, builds one point report (3 mi) as PDF, the default for one-site report links, and one county report as HTML. Each step is wrapped: a failure is logged and the API starts anyway.EJAM_WARMUP=falseskips it. Start-up log lines begin withEJAM warm-up:.main.r: runs the warm-up just beforer$run().rest_controller.r: newGET /warmup, which answers{"status":"ok"}at once withCache-Control: no-store. The EJAM app (Web app: wake the EJAM API when an EJAM user clicks Start (#772) EJAM#783) and EJSCREEN (EJSCREEN: wake the API when a user picks a Reports tool EJAM#773) will call it to wake the API before a report is needed. The Cloudflare Worker caches onlyGET /report, so/warmupalways reaches Cloud Run.Local test (Mac, EJAM 4.2024.0, API run from
main.r):Trade-off: start-up takes about 12 s longer locally. A report request that itself wakes the API still waits for the whole start-up, so it gains little. The gain comes when something else wakes the API first.
Not tested: Docker build, or Cloud Run. No overlap with #64 (that changes only
Dockerfileandcloudbuild.yaml).After merge: re-sync the EJAM repo's copy of
rest_controller.r(inst/plumber/ejam-api/, steps in itsSYNC.md); EJAM's mirror test fails until then.warmup.Ris not mirrored, likemain.r.— Claude (AI assistant), posting from ejanalysis account
🤖 Generated with Claude Code