2023-12-12 06:18:32 -08:00
|
|
|
import { Get, RestController } from '@/decorators';
|
2024-05-06 08:54:05 -07:00
|
|
|
import { ActiveWorkflowManager } from '@/ActiveWorkflowManager';
|
2024-01-22 02:16:29 -08:00
|
|
|
import { OrchestrationService } from '@/services/orchestration.service';
|
2023-12-12 06:18:32 -08:00
|
|
|
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
|
|
|
|
|
|
|
@RestController('/debug')
|
|
|
|
export class DebugController {
|
|
|
|
constructor(
|
2024-01-22 02:16:29 -08:00
|
|
|
private readonly orchestrationService: OrchestrationService,
|
2024-05-06 08:54:05 -07:00
|
|
|
private readonly activeWorkflowManager: ActiveWorkflowManager,
|
2023-12-12 06:18:32 -08:00
|
|
|
private readonly workflowRepository: WorkflowRepository,
|
|
|
|
) {}
|
|
|
|
|
2024-02-28 08:02:18 -08:00
|
|
|
@Get('/multi-main-setup', { skipAuth: true })
|
2023-12-12 06:18:32 -08:00
|
|
|
async getMultiMainSetupDetails() {
|
2024-01-22 02:16:29 -08:00
|
|
|
const leaderKey = await this.orchestrationService.multiMainSetup.fetchLeaderKey();
|
2023-12-12 06:18:32 -08:00
|
|
|
|
2023-12-28 04:14:10 -08:00
|
|
|
const triggersAndPollers = await this.workflowRepository.findIn(
|
2024-05-06 08:54:05 -07:00
|
|
|
this.activeWorkflowManager.allActiveInMemory(),
|
2023-12-28 04:14:10 -08:00
|
|
|
);
|
2023-12-12 06:18:32 -08:00
|
|
|
|
2023-12-28 04:14:10 -08:00
|
|
|
const webhooks = await this.workflowRepository.findWebhookBasedActiveWorkflows();
|
2023-12-27 07:55:01 -08:00
|
|
|
|
2024-05-06 08:54:05 -07:00
|
|
|
const activationErrors = await this.activeWorkflowManager.getAllWorkflowActivationErrors();
|
2023-12-12 06:18:32 -08:00
|
|
|
|
|
|
|
return {
|
2024-01-22 02:16:29 -08:00
|
|
|
instanceId: this.orchestrationService.instanceId,
|
2023-12-12 06:18:32 -08:00
|
|
|
leaderKey,
|
2024-01-22 02:16:29 -08:00
|
|
|
isLeader: this.orchestrationService.isLeader,
|
2023-12-27 07:55:01 -08:00
|
|
|
activeWorkflows: {
|
|
|
|
webhooks, // webhook-based active workflows
|
|
|
|
triggersAndPollers, // poller- and trigger-based active workflows
|
|
|
|
},
|
2023-12-12 06:18:32 -08:00
|
|
|
activationErrors,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|