mirror of
https://github.com/immich-app/immich
synced 2026-08-22 13:13:05 +00:00
refactor: deduplicate code between api/maintenance workers
This commit is contained in:
parent
3de75cc768
commit
428cbcea3a
3 changed files with 24 additions and 85 deletions
|
|
@ -14,15 +14,16 @@ import { bootstrapTelemetry } from 'src/repositories/telemetry.repository';
|
|||
import { ApiService } from 'src/services/api.service';
|
||||
import { MaintenanceService } from 'src/services/maintenance.service';
|
||||
import { isStartUpError, useSwagger } from 'src/utils/misc';
|
||||
async function bootstrap() {
|
||||
process.title = 'immich-api';
|
||||
|
||||
export async function bootstrapApi(title: string = 'immich-api', module = ApiModule) {
|
||||
process.title = title;
|
||||
|
||||
const { telemetry, network } = new ConfigRepository().getEnv();
|
||||
if (telemetry.metrics.size > 0) {
|
||||
bootstrapTelemetry(telemetry.apiPort);
|
||||
}
|
||||
|
||||
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { bufferLogs: true });
|
||||
const app = await NestFactory.create<NestExpressApplication>(module, { bufferLogs: true });
|
||||
const logger = await app.resolve(LoggingRepository);
|
||||
const configRepository = app.get(ConfigRepository);
|
||||
app.get(MaintenanceService).nestApplication = app;
|
||||
|
|
@ -68,10 +69,12 @@ async function bootstrap() {
|
|||
logger.log(`Immich Server is listening on ${await app.getUrl()} [v${serverVersion}] [${environment}] `);
|
||||
}
|
||||
|
||||
bootstrap().catch((error) => {
|
||||
if (!isStartUpError(error)) {
|
||||
console.error(error);
|
||||
}
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
process.exit(1);
|
||||
});
|
||||
if (require.main === module) {
|
||||
bootstrapApi().catch((error) => {
|
||||
if (!isStartUpError(error)) {
|
||||
console.error(error);
|
||||
}
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue