mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(server): telemetry ports env (#13560)
This commit is contained in:
parent
0eabb3ef80
commit
c8f672f494
6 changed files with 80 additions and 18 deletions
|
|
@ -10,25 +10,17 @@ import { ImmichEnvironment } from 'src/enum';
|
|||
import { IConfigRepository } from 'src/interfaces/config.interface';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { WebSocketAdapter } from 'src/middleware/websocket.adapter';
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { ApiService } from 'src/services/api.service';
|
||||
import { isStartUpError } from 'src/services/storage.service';
|
||||
import { otelStart } from 'src/utils/instrumentation';
|
||||
import { useSwagger } from 'src/utils/misc';
|
||||
|
||||
function parseTrustedProxy(input?: string) {
|
||||
if (!input) {
|
||||
return [];
|
||||
}
|
||||
// Split on ',' char to allow multiple IPs
|
||||
return input.split(',');
|
||||
}
|
||||
|
||||
async function bootstrap() {
|
||||
process.title = 'immich-api';
|
||||
const otelPort = Number.parseInt(process.env.IMMICH_API_METRICS_PORT ?? '8081');
|
||||
const trustedProxies = parseTrustedProxy(process.env.IMMICH_TRUSTED_PROXIES ?? '');
|
||||
|
||||
otelStart(otelPort);
|
||||
const { telemetry, network } = new ConfigRepository().getEnv();
|
||||
otelStart(telemetry.apiPort);
|
||||
|
||||
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { bufferLogs: true });
|
||||
const logger = await app.resolve<ILoggerRepository>(ILoggerRepository);
|
||||
|
|
@ -39,7 +31,7 @@ async function bootstrap() {
|
|||
|
||||
logger.setContext('Bootstrap');
|
||||
app.useLogger(logger);
|
||||
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal', ...trustedProxies]);
|
||||
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal', ...network.trustedProxies]);
|
||||
app.set('etag', 'strong');
|
||||
app.use(cookieParser());
|
||||
app.use(json({ limit: '10mb' }));
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ 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 { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { isStartUpError } from 'src/services/storage.service';
|
||||
import { otelStart } from 'src/utils/instrumentation';
|
||||
|
||||
export async function bootstrap() {
|
||||
const otelPort = Number.parseInt(process.env.IMMICH_MICROSERVICES_METRICS_PORT ?? '8082');
|
||||
|
||||
otelStart(otelPort);
|
||||
const { telemetry } = new ConfigRepository().getEnv();
|
||||
otelStart(telemetry.microservicesPort);
|
||||
|
||||
const app = await NestFactory.create(MicroservicesModule, { bufferLogs: true });
|
||||
const logger = await app.resolve(ILoggerRepository);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue