1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

refactor(server): server version logging (#1073)

* refactor(server): server version logging

* chore: server => microservices
This commit is contained in:
Jason Rasmussen 2022-12-08 10:53:18 -05:00 committed by GitHub
parent c23b2479f7
commit 58a149990d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 26 deletions

View File

@ -14,3 +14,5 @@ export const serverVersion: IServerVersion = {
patch: 0, patch: 0,
build: 58, build: 58,
}; };
export const SERVER_VERSION = `${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`;

View File

@ -6,11 +6,13 @@ import cookieParser from 'cookie-parser';
import { writeFileSync } from 'fs'; import { writeFileSync } from 'fs';
import path from 'path'; import path from 'path';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { serverVersion } from './constants/server_version.constant'; import { SERVER_VERSION } from './constants/server_version.constant';
import { RedisIoAdapter } from './middlewares/redis-io.adapter.middleware'; import { RedisIoAdapter } from './middlewares/redis-io.adapter.middleware';
import { json } from 'body-parser'; import { json } from 'body-parser';
import { patchOpenAPI } from './utils/patch-open-api.util'; import { patchOpenAPI } from './utils/patch-open-api.util';
const logger = new Logger('ImmichServer');
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule); const app = await NestFactory.create<NestExpressApplication>(AppModule);
@ -27,7 +29,7 @@ async function bootstrap() {
const config = new DocumentBuilder() const config = new DocumentBuilder()
.setTitle('Immich') .setTitle('Immich')
.setDescription('Immich API') .setDescription('Immich API')
.setVersion(`${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`) .setVersion(SERVER_VERSION)
.addBearerAuth({ .addBearerAuth({
type: 'http', type: 'http',
scheme: 'Bearer', scheme: 'Bearer',
@ -57,18 +59,10 @@ async function bootstrap() {
// Generate API Documentation only in development mode // Generate API Documentation only in development mode
const outputPath = path.resolve(process.cwd(), 'immich-openapi-specs.json'); const outputPath = path.resolve(process.cwd(), 'immich-openapi-specs.json');
writeFileSync(outputPath, JSON.stringify(patchOpenAPI(apiDocument), null, 2), { encoding: 'utf8' }); writeFileSync(outputPath, JSON.stringify(patchOpenAPI(apiDocument), null, 2), { encoding: 'utf8' });
Logger.log(
`Running Immich Server in DEVELOPMENT environment - version ${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`,
'ImmichServer',
);
} }
if (process.env.NODE_ENV == 'production') { const envName = (process.env.NODE_ENV || 'development').toUpperCase();
Logger.log( logger.log(`Running Immich Server in ${envName} environment - version ${SERVER_VERSION}`);
`Running Immich Server in PRODUCTION environment - version ${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`,
'ImmichServer',
);
}
}); });
} }
bootstrap(); bootstrap();

View File

@ -1,28 +1,19 @@
import { Logger } from '@nestjs/common'; import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { serverVersion } from 'apps/immich/src/constants/server_version.constant'; import { SERVER_VERSION } from 'apps/immich/src/constants/server_version.constant';
import { RedisIoAdapter } from '../../immich/src/middlewares/redis-io.adapter.middleware'; import { RedisIoAdapter } from '../../immich/src/middlewares/redis-io.adapter.middleware';
import { MicroservicesModule } from './microservices.module'; import { MicroservicesModule } from './microservices.module';
const logger = new Logger('ImmichMicroservice');
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(MicroservicesModule); const app = await NestFactory.create(MicroservicesModule);
app.useWebSocketAdapter(new RedisIoAdapter(app)); app.useWebSocketAdapter(new RedisIoAdapter(app));
await app.listen(3002, () => { await app.listen(3002, () => {
if (process.env.NODE_ENV == 'development') { const envName = (process.env.NODE_ENV || 'development').toUpperCase();
Logger.log( logger.log(`Running Immich Microservices in ${envName} environment - version ${SERVER_VERSION}`);
`Running Immich Microservices in DEVELOPMENT environment - version ${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`,
'ImmichMicroservice',
);
}
if (process.env.NODE_ENV == 'production') {
Logger.log(
`Running Immich Microservices in PRODUCTION environment - version ${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`,
'ImmichMicroservice',
);
}
}); });
} }
bootstrap(); bootstrap();