|
1 | | -import executorTask from '~/_common/tasks/executor.task'; |
| 1 | +import { executorTask } from '~/_common/tasks/executor.task'; |
2 | 2 | import { BackendRunnerService } from '../backend-runner.service'; |
3 | 3 | import { ExecutorExecuteResponseInterface, ExecutorInterface } from '../executors.interface'; |
4 | 4 | import { join } from 'path'; |
5 | 5 | import { Job } from 'bullmq'; |
6 | 6 | import { BackendConfigV1Dto } from '../_dto/backend-config-v1.dto'; |
7 | 7 | import { BackendResultInterface } from '../_interfaces/backend-result.interface'; |
8 | | -import { ExecutorConfigInterface } from '~/_common/interfaces/executor-config.interface'; |
| 8 | +import { BackendCodesEnum } from '../_interfaces/backend-codes.enum'; |
9 | 9 |
|
10 | 10 | export class CatchAllExecutor implements ExecutorInterface { |
11 | 11 | public constructor(public service: BackendRunnerService) {} |
@@ -39,30 +39,33 @@ export class CatchAllExecutor implements ExecutorInterface { |
39 | 39 | } |
40 | 40 |
|
41 | 41 | public async executeBackend(job: Job, backend: BackendConfigV1Dto): Promise<BackendResultInterface> { |
42 | | - const process = await executorTask(join(backend.path, 'bin', backend.actions[job.name].exec), job, { |
43 | | - ...this.service.config.get<ExecutorConfigInterface>('backendExecutorConfig'), |
| 42 | + const process = await executorTask(join(backend.path, 'bin', backend.actions[job.name].script), job, { |
| 43 | + ...this.service.backendExecutorConfig, |
44 | 44 | }); |
45 | 45 |
|
46 | 46 | try { |
47 | 47 | if (process.status !== 0) { |
| 48 | + this.service.logger.error(`Error executing backend ${backend.name}`); |
48 | 49 | return { |
49 | 50 | backend: backend.name, |
50 | 51 | status: process.status, |
51 | 52 | error: JSON.parse(process.output), |
52 | 53 | }; |
53 | 54 | } |
54 | 55 |
|
| 56 | + this.service.logger.log(`Backend ${backend.name} executed successfully`); |
55 | 57 | return { |
56 | 58 | backend: backend.name, |
57 | 59 | status: process.status, |
58 | 60 | output: JSON.parse(process.output), |
59 | 61 | }; |
60 | 62 | } catch (e) { |
| 63 | + this.service.logger.error(`Error parsing JSON output from backend ${backend.name}`); |
61 | 64 | return { |
62 | 65 | backend: backend.name, |
63 | | - status: process.status, |
| 66 | + status: BackendCodesEnum.INVALID_JSON_RESPONSE, |
64 | 67 | error: { |
65 | | - status: process.status, |
| 68 | + status: BackendCodesEnum.INVALID_JSON_RESPONSE, |
66 | 69 | message: process.error, |
67 | 70 | }, |
68 | 71 | }; |
|
0 commit comments