feat(geoportal): N8N webhook on sync completion + tile cache monitoring
- weekend-deep-sync.ts: fire webhook to N8N_WEBHOOK_URL after each sync cycle (N8N triggers tippecanoe PMTiles rebuild via SSH on host) - nginx tile-cache: add stub_status at /status, custom log format with cache status - Add tile-cache-stats.sh: shows HIT/MISS ratio, cache size, slow tiles - docker-compose: add N8N_WEBHOOK_URL env var Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -401,6 +401,8 @@ export async function runWeekendDeepSync(): Promise<void> {
|
||||
console.log(
|
||||
`[weekend-sync] Ciclu complet #${state.completedCycles}! Reset pentru urmatorul ciclu.`,
|
||||
);
|
||||
// Notify N8N to rebuild PMTiles (overview tiles for geoportal)
|
||||
await fireSyncWebhook(state.completedCycles);
|
||||
}
|
||||
|
||||
await saveState(state);
|
||||
@@ -534,3 +536,28 @@ async function sendStatusEmail(
|
||||
console.warn(`[weekend-sync] Nu s-a putut trimite email: ${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* N8N Webhook — trigger PMTiles rebuild after sync cycle */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
async function fireSyncWebhook(cycle: number): Promise<void> {
|
||||
const url = process.env.N8N_WEBHOOK_URL;
|
||||
if (!url) return;
|
||||
|
||||
try {
|
||||
await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
event: "weekend-sync-cycle-complete",
|
||||
cycle,
|
||||
timestamp: new Date().toISOString(),
|
||||
}),
|
||||
});
|
||||
console.log(`[weekend-sync] Webhook trimis la N8N (ciclu #${cycle})`);
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
console.warn(`[weekend-sync] Webhook N8N esuat: ${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user