Improve graphs backfill resilience
All checks were successful
Build and Deploy / build-and-push (push) Successful in 2m56s

This commit is contained in:
Cauê Faleiros
2026-07-03 12:19:43 -03:00
parent 83f165381d
commit 831f82ee57
2 changed files with 187 additions and 31 deletions

View File

@@ -34,6 +34,14 @@ app.get('/api/trigger-backfill', (req: Request, res: Response) => {
detached: true,
stdio: 'inherit' // Inherit allows the logs to show up in Portainer's log viewer!
});
child.on('error', (error) => {
console.error(`[server]: Backfill process failed to start: ${error.message}`);
});
child.on('exit', (code, signal) => {
console.log(`[server]: Backfill process exited. code=${code ?? 'null'} signal=${signal ?? 'null'}`);
});
child.unref();
@@ -60,6 +68,7 @@ app.get('/api/trigger-graphs-backfill', (req: Request, res: Response) => {
maxOrders: 'GRAPHS_BACKFILL_MAX_ORDERS',
maxDays: 'GRAPHS_BACKFILL_MAX_DAYS',
contactFallback: 'GRAPHS_BACKFILL_CONTACT_FALLBACK',
sellerFallback: 'GRAPHS_BACKFILL_SELLER_FALLBACK',
tinyRequestDelayMs: 'GRAPHS_BACKFILL_TINY_REQUEST_DELAY_MS',
orderDelayMs: 'GRAPHS_BACKFILL_ORDER_DELAY_MS',
blockDelayMs: 'GRAPHS_BACKFILL_TINY_BLOCK_DELAY_MS',
@@ -83,6 +92,14 @@ app.get('/api/trigger-graphs-backfill', (req: Request, res: Response) => {
env
});
child.on('error', (error) => {
console.error(`[server]: Graphs backfill process failed to start: ${error.message}`);
});
child.on('exit', (code, signal) => {
console.log(`[server]: Graphs backfill process exited. code=${code ?? 'null'} signal=${signal ?? 'null'}`);
});
child.unref();
console.log('[server]: Graphs backfill script manually triggered via HTTP endpoint.');
@@ -96,6 +113,7 @@ app.get('/api/trigger-graphs-backfill', (req: Request, res: Response) => {
maxOrders: env.GRAPHS_BACKFILL_MAX_ORDERS || null,
maxDays: env.GRAPHS_BACKFILL_MAX_DAYS || null,
contactFallback: env.GRAPHS_BACKFILL_CONTACT_FALLBACK || 'true',
sellerFallback: env.GRAPHS_BACKFILL_SELLER_FALLBACK || 'true',
tinyRequestDelayMs: env.GRAPHS_BACKFILL_TINY_REQUEST_DELAY_MS || '6000',
orderDelayMs: env.GRAPHS_BACKFILL_ORDER_DELAY_MS || '0',
blockDelayMs: env.GRAPHS_BACKFILL_TINY_BLOCK_DELAY_MS || '600000',