Files
twenty/packages/twenty-server/src/command/command.ts
Charles Bochet d022837b5b Display command logs on boot error (#6414)
As per title
2024-07-25 17:53:57 +02:00

37 lines
1.1 KiB
TypeScript

import { CommandFactory } from 'nest-commander';
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
import { LoggerService } from 'src/engine/integrations/logger/logger.service';
import { shouldFilterException } from 'src/engine/utils/global-exception-handler.util';
import { CommandModule } from './command.module';
async function bootstrap() {
const errorHandler = (err: Error) => {
loggerService.error(err?.message, err?.name);
if (shouldFilterException(err)) {
return;
}
exceptionHandlerService.captureExceptions([err]);
};
const app = await CommandFactory.createWithoutRunning(CommandModule, {
logger: ['error', 'warn', 'log'],
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
errorHandler,
serviceErrorHandler: errorHandler,
});
const loggerService = app.get(LoggerService);
const exceptionHandlerService = app.get(ExceptionHandlerService);
// Inject our logger
app.useLogger(loggerService);
await CommandFactory.runApplication(app);
app.close();
}
bootstrap();