Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions tools/render/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,18 @@ curl -o out.pptx 'http://127.0.0.1:4310/render/R-HSA-109606.pptx'
curl -s http://127.0.0.1:4310/health
```

| variable | default | |
| -------------------- | --------------------- | -------------------------------------------------------------------------- |
| `RENDER_PORT` | 4310 | |
| `RENDER_HOST` | 127.0.0.1 | set `0.0.0.0` only behind something that decides who may cause work |
| `RENDER_BASE` | http://localhost:4200 | site to render against |
| `RENDER_CACHE` | `.render-cache` | |
| `RENDER_CACHE_KEY` | the code's (`v12`) | override only to invalidate by hand; the code bumps it when output changes |
| `RENDER_CONCURRENCY` | 2 | simultaneous renders |
| `RENDER_QUEUE` | 8 | pending renders before 503 |
| `RENDER_TIMEOUT` | 45000 | ms before a render is abandoned |
| `RENDER_FILES` | unset | a folder laid out as the download site; see below |
| variable | default | |
| -------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `RENDER_PORT` | 4310 | |
| `RENDER_HOST` | 127.0.0.1 | set `0.0.0.0` only behind something that decides who may cause work |
| `RENDER_BASE` | http://localhost:4200 | site to render against |
| `RENDER_CACHE` | `.render-cache` | |
| `RENDER_CACHE_KEY` | the code's (`v12`) | override only to invalidate by hand; the code bumps it when output changes |
| `RENDER_CACHE_MAX` | 2 GB | bytes of figures kept; 0 keeps everything. The cache cannot be turned off: for a cold run, give a fresh `RENDER_CACHE_KEY` |
| `RENDER_CONCURRENCY` | 2 | simultaneous renders |
| `RENDER_QUEUE` | 8 | pending renders before 503 |
| `RENDER_TIMEOUT` | 45000 | ms before a render is abandoned |
| `RENDER_FILES` | unset | a folder laid out as the download site; see below |

**The release's files.** The render page fetches a diagram's layout
(`{release}/diagram/{id}.json`, `.graph.json`) and an illustration
Expand Down
17 changes: 10 additions & 7 deletions tools/render/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
* RENDER_CACHE_KEY salt; change it to invalidate everything (e.g. release)
* RENDER_CONCURRENCY simultaneous renders, default 2
* RENDER_QUEUE pending renders before 503, default 8
* RENDER_CACHE_MAX bytes of cache to keep, default 2 GB (0 disables)
* RENDER_CACHE_MAX bytes of cache to keep, default 2 GB (0: no limit; the
* cache cannot be turned off -- a fresh RENDER_CACHE_KEY is cold)
* RENDER_TIMEOUT ms before a render is abandoned, default 45000
* RENDER_FILES a folder laid out as the download site, read instead of it
* (local-files.ts); unset, the page fetches from the site
Expand Down Expand Up @@ -111,12 +112,6 @@ const CACHE_KEY = process.env['RENDER_CACHE_KEY'] || 'v12';
// for the page to read instead of the site (local-files.ts). Unset, it fetches
// them from the site, as a reader's browser does.
const FILES = process.env['RENDER_FILES'] || undefined;
// A mistyped folder would otherwise fail every render after the full timeout,
// with /health saying the files are local.
if (FILES && !statSync(FILES, { throwIfNoEntry: false })?.isDirectory()) {
console.error(`RENDER_FILES is not a directory: ${FILES}`);
process.exit(2);
}
const CONCURRENCY = Number(process.env['RENDER_CONCURRENCY'] || 2);
// Generous next to a real render, which is 3-8s, but far short of the two
// minutes a page that never becomes ready would otherwise hold a browser for.
Expand Down Expand Up @@ -773,6 +768,14 @@ function startedDirectly() {
}

const started = startedDirectly();
// A mistyped folder would otherwise fail every render after the full timeout,
// with /health saying the files are local. Checked only when the service is
// started, so a test importing this module is never stopped by the shell's
// RENDER_FILES.
if (started && FILES && !statSync(FILES, { throwIfNoEntry: false })?.isDirectory()) {
console.error(`RENDER_FILES is not a directory: ${FILES}`);
process.exit(2);
}
const server = started
? app.listen(PORT, HOST, () => {
console.log(`render service on http://${HOST}:${PORT}`);
Expand Down
Loading