mirror of
https://github.com/rmdes/indiekit-startup-gate.git
synced 2026-06-24 15:03:44 +00:00
No description
- JavaScript 100%
| CLAUDE.md | ||
| index.js | ||
| package.json | ||
| README.md | ||
@rmdes/indiekit-startup-gate
Defers Indiekit plugin background tasks until the host signals readiness.
Problem
On deployment, Indiekit plugins start background work (feed polling, federation queues, sync jobs) immediately — competing for resources with the Eleventy site build. This package gates heavy tasks behind a file-based readiness signal.
Usage
import { waitForReady } from "@rmdes/indiekit-startup-gate";
// In your plugin's init():
this._stopGate = waitForReady(
() => {
startPolling(indiekit, options);
},
{ label: "MyPlugin" },
);
// In your plugin's destroy():
this._stopGate?.();
How It Works
- The deployment script (
start.sh) removes/app/data/.indiekit-readybefore the Eleventy build - Plugins call
waitForReady(callback)— if the file doesn't exist, they poll every 5 seconds - After the build completes and the atomic symlink swap happens,
start.shcreates the file - Plugins detect the file and start their background tasks
- If the file already exists (hot restart, dev mode), the callback fires immediately
API
waitForReady(callback, options?)
- callback
Function— Called when the readiness signal is detected - options.label
string— Plugin name for log messages (default:"plugin") - Returns
Function— Call to cancel polling (for plugindestroy()lifecycle)
Log Output
[startup-gate] MyPlugin: waiting for readiness signal...
[startup-gate] MyPlugin: ready — starting deferred tasks
Signal File
Default path: /app/data/.indiekit-ready
Currently hardcoded for Cloudron deployments. Will be made configurable for other deployment methods.