mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-04-02 16:44:56 +02:00
Full OG regeneration (2,350 images) OOM-kills when the Eleventy watcher is running (~1.8 GB RSS), leaving only ~1.2 GB headroom in the 3 GB container. WASM native memory from Satori/Resvg grows beyond what GC can reclaim within a single process. Solution: spawn og-cli in batches of 100 images. Each invocation exits after its batch, fully releasing all WASM native memory. Exit code 2 signals "more work remains" and the spawner re-loops. Peak memory per batch stays under ~500 MB regardless of total image count. Also seed newManifest from existing manifest so unscanned entries survive batch writes. Confab-Link: http://localhost:8080/sessions/edb1b7b0-da66-4486-bd9c-d1cfa7553b88
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* CLI entry point for OG image generation.
|
|
* Runs as a separate process to isolate memory from Eleventy.
|
|
*
|
|
* Usage: node lib/og-cli.js <contentDir> <cacheDir> <siteName> [batchSize]
|
|
*
|
|
* batchSize: Max images to generate per invocation (0 = unlimited).
|
|
* When set, exits after generating that many images so the caller
|
|
* can re-spawn (releasing all WASM native memory between batches).
|
|
* Exit code 2 = batch complete, more work remains.
|
|
*/
|
|
|
|
import { generateOgImages } from "./og.js";
|
|
|
|
const [contentDir, cacheDir, siteName, batchSizeStr] = process.argv.slice(2);
|
|
|
|
if (!contentDir || !cacheDir || !siteName) {
|
|
console.error("[og] Usage: node og-cli.js <contentDir> <cacheDir> <siteName> [batchSize]");
|
|
process.exit(1);
|
|
}
|
|
|
|
const batchSize = parseInt(batchSizeStr, 10) || 0;
|
|
const result = await generateOgImages(contentDir, cacheDir, siteName, batchSize);
|
|
|
|
// Exit code 2 signals "batch complete, more images remain"
|
|
if (result?.hasMore) {
|
|
process.exit(2);
|
|
}
|