fix: write heartbeat file for Docker healthcheck
This commit is contained in:
@@ -57,11 +57,6 @@ const PIPELINE_GROUPS: PipelineGroup[] = [
|
|||||||
{ name: 'kerknet-import', type: 'kerknet-import', config: {} },
|
{ name: 'kerknet-import', type: 'kerknet-import', config: {} },
|
||||||
{ name: 'gottesdienstzeiten-import', type: 'gottesdienstzeiten-import', config: {} },
|
{ name: 'gottesdienstzeiten-import', type: 'gottesdienstzeiten-import', config: {} },
|
||||||
{ name: 'masstimes-api-import', type: 'masstimes-api-import', config: {} },
|
{ name: 'masstimes-api-import', type: 'masstimes-api-import', config: {} },
|
||||||
{ name: 'buscarmisas-network-BR', type: 'buscarmisas-network-BR', config: {} },
|
|
||||||
{ name: 'buscarmisas-network-MX', type: 'buscarmisas-network-MX', config: {} },
|
|
||||||
{ name: 'buscarmisas-network-AR', type: 'buscarmisas-network-AR', config: {} },
|
|
||||||
{ name: 'buscarmisas-network-CO', type: 'buscarmisas-network-CO', config: {} },
|
|
||||||
{ name: 'buscarmisas-network-CL', type: 'buscarmisas-network-CL', config: {} },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -241,31 +236,6 @@ function getJobCommand(type: string, language?: string | null, config?: Record<s
|
|||||||
if (config?.region) args.splice(2, 1, '--region', String(config.region)); // replace --all with --region
|
if (config?.region) args.splice(2, 1, '--region', String(config.region)); // replace --all with --region
|
||||||
return { command: 'npx', args };
|
return { command: 'npx', args };
|
||||||
}
|
}
|
||||||
case 'buscarmisas-network-BR': {
|
|
||||||
const args = ['tsx', 'scripts/import-buscarmisas-network.ts', '--domain', 'horariosmissa.com.br'];
|
|
||||||
if (config?.resumeFrom) args.push('--resume-from', String(config.resumeFrom));
|
|
||||||
return { command: 'npx', args };
|
|
||||||
}
|
|
||||||
case 'buscarmisas-network-MX': {
|
|
||||||
const args = ['tsx', 'scripts/import-buscarmisas-network.ts', '--domain', 'buscarmisas.com.mx'];
|
|
||||||
if (config?.resumeFrom) args.push('--resume-from', String(config.resumeFrom));
|
|
||||||
return { command: 'npx', args };
|
|
||||||
}
|
|
||||||
case 'buscarmisas-network-AR': {
|
|
||||||
const args = ['tsx', 'scripts/import-buscarmisas-network.ts', '--domain', 'horariosmisa.com.ar'];
|
|
||||||
if (config?.resumeFrom) args.push('--resume-from', String(config.resumeFrom));
|
|
||||||
return { command: 'npx', args };
|
|
||||||
}
|
|
||||||
case 'buscarmisas-network-CO': {
|
|
||||||
const args = ['tsx', 'scripts/import-buscarmisas-network.ts', '--domain', 'buscarmisas.co'];
|
|
||||||
if (config?.resumeFrom) args.push('--resume-from', String(config.resumeFrom));
|
|
||||||
return { command: 'npx', args };
|
|
||||||
}
|
|
||||||
case 'buscarmisas-network-CL': {
|
|
||||||
const args = ['tsx', 'scripts/import-buscarmisas-network.ts', '--domain', 'horariomisa.cl'];
|
|
||||||
if (config?.resumeFrom) args.push('--resume-from', String(config.resumeFrom));
|
|
||||||
return { command: 'npx', args };
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown job type: ${type}`);
|
throw new Error(`Unknown job type: ${type}`);
|
||||||
}
|
}
|
||||||
@@ -773,7 +743,7 @@ async function main(): Promise<void> {
|
|||||||
cron.schedule('0 */6 * * *', () => cleanStaleJobs(), { timezone: 'UTC' });
|
cron.schedule('0 */6 * * *', () => cleanStaleJobs(), { timezone: 'UTC' });
|
||||||
log('Registered cron job: stale-job-cleanup (every 6h)');
|
log('Registered cron job: stale-job-cleanup (every 6h)');
|
||||||
|
|
||||||
// Heartbeat every hour — logs cycle state
|
// Heartbeat every hour — logs cycle state and writes heartbeat file for Docker healthcheck
|
||||||
cron.schedule('0 * * * *', () => {
|
cron.schedule('0 * * * *', () => {
|
||||||
const currentGroup = cycleState.currentGroupIndex < PIPELINE_GROUPS.length
|
const currentGroup = cycleState.currentGroupIndex < PIPELINE_GROUPS.length
|
||||||
? PIPELINE_GROUPS[cycleState.currentGroupIndex].name
|
? PIPELINE_GROUPS[cycleState.currentGroupIndex].name
|
||||||
@@ -785,6 +755,7 @@ async function main(): Promise<void> {
|
|||||||
? 'cooldown'
|
? 'cooldown'
|
||||||
: `group ${cycleState.currentGroupIndex + 1}/${PIPELINE_GROUPS.length} (${currentGroup})`;
|
: `group ${cycleState.currentGroupIndex + 1}/${PIPELINE_GROUPS.length} (${currentGroup})`;
|
||||||
log(`Heartbeat: Cycle ${cycleState.cycleNumber + 1}, ${state}. ${jobs}`);
|
log(`Heartbeat: Cycle ${cycleState.cycleNumber + 1}, ${state}. ${jobs}`);
|
||||||
|
fs.writeFileSync(path.join(LOGS_DIR, 'scheduler.heartbeat'), new Date().toISOString());
|
||||||
}, { timezone: 'UTC' });
|
}, { timezone: 'UTC' });
|
||||||
log('Registered cron job: heartbeat (hourly)');
|
log('Registered cron job: heartbeat (hourly)');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user