Skip to content

High performance self-hosted photo and video management solution.

refactor(server): immich app env (#13169)

Jason Rasmussen9edc9d615149
diff --git a/server/src/app.module.ts b/server/src/app.module.ts
index 55b9babcb4..4d1c7946c6 100644
--- a/server/src/app.module.ts
+++ b/server/src/app.module.ts
@@ -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);
diff --git a/server/src/constants.ts b/server/src/constants.ts
index c62c06ffa2..26c9ef5a98 100644
--- a/server/src/constants.ts
+++ b/server/src/constants.ts
@@ -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;
diff --git a/server/src/workers/api.ts b/server/src/workers/api.ts
index d12d092ea1..7c80ec0666 100644
--- a/server/src/workers/api.ts
+++ b/server/src/workers/api.ts
@@ -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) => {
diff --git a/server/src/workers/microservices.ts b/server/src/workers/microservices.ts
index 789b6f5287..32eac60117 100644
--- a/server/src/workers/microservices.ts
+++ b/server/src/workers/microservices.ts
@@ -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) {