mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
refactor(server): immich app env (#13169)
This commit is contained in:
parent
3ac00b0ffa
commit
9edc9d6151
4 changed files with 14 additions and 8 deletions
|
@ -66,7 +66,9 @@ export class ApiModule implements OnModuleInit, OnModuleDestroy {
|
|||
private moduleRef: ModuleRef,
|
||||
@Inject(IEventRepository) private eventRepository: IEventRepository,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
) {}
|
||||
) {
|
||||
logger.setAppName('Api');
|
||||
}
|
||||
|
||||
async onModuleInit() {
|
||||
const items = setupEventHandlers(this.moduleRef);
|
||||
|
@ -95,7 +97,10 @@ export class MicroservicesModule implements OnModuleInit, OnModuleDestroy {
|
|||
constructor(
|
||||
private moduleRef: ModuleRef,
|
||||
@Inject(IEventRepository) private eventRepository: IEventRepository,
|
||||
) {}
|
||||
@Inject(ILoggerRepository) logger: ILoggerRepository,
|
||||
) {
|
||||
logger.setAppName('Microservices');
|
||||
}
|
||||
|
||||
async onModuleInit() {
|
||||
setupEventHandlers(this.moduleRef);
|
||||
|
|
|
@ -20,7 +20,6 @@ export const serverVersion = new SemVer(version);
|
|||
export const AUDIT_LOG_MAX_DURATION = Duration.fromObject({ days: 100 });
|
||||
export const ONE_HOUR = Duration.fromObject({ hours: 1 });
|
||||
|
||||
export const envName = (process.env.IMMICH_ENV || 'production').toUpperCase();
|
||||
export const APP_MEDIA_LOCATION = process.env.IMMICH_MEDIA_LOCATION || './upload';
|
||||
const HOST_SERVER_PORT = process.env.IMMICH_PORT || '2283';
|
||||
export const DEFAULT_EXTERNAL_DOMAIN = 'http://localhost:' + HOST_SERVER_PORT;
|
||||
|
|
|
@ -5,7 +5,7 @@ import cookieParser from 'cookie-parser';
|
|||
import { existsSync } from 'node:fs';
|
||||
import sirv from 'sirv';
|
||||
import { ApiModule } from 'src/app.module';
|
||||
import { envName, excludePaths, resourcePaths, serverVersion } from 'src/constants';
|
||||
import { excludePaths, resourcePaths, serverVersion } from 'src/constants';
|
||||
import { ImmichEnvironment } from 'src/enum';
|
||||
import { IConfigRepository } from 'src/interfaces/config.interface';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
|
@ -39,7 +39,6 @@ async function bootstrap() {
|
|||
const { environment, port } = configRepository.getEnv();
|
||||
const isDev = environment === ImmichEnvironment.DEVELOPMENT;
|
||||
|
||||
logger.setAppName('Api');
|
||||
logger.setContext('Bootstrap');
|
||||
app.useLogger(logger);
|
||||
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal', ...trustedProxies]);
|
||||
|
@ -75,7 +74,7 @@ async function bootstrap() {
|
|||
const server = await (host ? app.listen(port, host) : app.listen(port));
|
||||
server.requestTimeout = 30 * 60 * 1000;
|
||||
|
||||
logger.log(`Immich Server is listening on ${await app.getUrl()} [v${serverVersion}] [${envName}] `);
|
||||
logger.log(`Immich Server is listening on ${await app.getUrl()} [v${serverVersion}] [${environment}] `);
|
||||
}
|
||||
|
||||
bootstrap().catch((error) => {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { NestFactory } from '@nestjs/core';
|
||||
import { isMainThread } from 'node:worker_threads';
|
||||
import { MicroservicesModule } from 'src/app.module';
|
||||
import { envName, serverVersion } from 'src/constants';
|
||||
import { serverVersion } from 'src/constants';
|
||||
import { IConfigRepository } from 'src/interfaces/config.interface';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { WebSocketAdapter } from 'src/middleware/websocket.adapter';
|
||||
import { isStartUpError } from 'src/utils/events';
|
||||
|
@ -21,7 +22,9 @@ export async function bootstrap() {
|
|||
|
||||
await app.listen(0);
|
||||
|
||||
logger.log(`Immich Microservices is running [v${serverVersion}] [${envName}] `);
|
||||
const configRepository = app.get<IConfigRepository>(IConfigRepository);
|
||||
const { environment } = configRepository.getEnv();
|
||||
logger.log(`Immich Microservices is running [v${serverVersion}] [${environment}] `);
|
||||
}
|
||||
|
||||
if (!isMainThread) {
|
||||
|
|
Loading…
Reference in a new issue