Skip to content

Commit 539a5c4

Browse files
author
Artem
committed
final changes
1 parent 4e44124 commit 539a5c4

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

redisinsight/api/config/default.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ export default {
9090
unsupportedCommands: JSON.parse(process.env.CLI_UNSUPPORTED_COMMANDS || '[]'),
9191
},
9292
profiler: {
93-
// logFileIdleThreshold: parseInt(process.env.PROFILER_LOG_FILE_IDLE_THRESHOLD, 10) || 1000 * 60, // 1min
94-
logFileIdleThreshold: parseInt(process.env.PROFILER_LOG_FILE_IDLE_THRESHOLD, 10) || 1000 * 10, // 1min
93+
logFileIdleThreshold: parseInt(process.env.PROFILER_LOG_FILE_IDLE_THRESHOLD, 10) || 1000 * 60, // 1min
9594
},
9695
analytics: {
9796
writeKey: process.env.SEGMENT_WRITE_KEY || 'SOURCE_WRITE_KEY',

redisinsight/api/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export default async function bootstrap() {
4444
);
4545
}
4646

47+
app.enableShutdownHooks();
48+
4749
await app.listen(port);
4850
logger.log({
4951
message: `Server is running on http(s)://localhost:${port}`,

redisinsight/api/src/modules/profiler/providers/log-file.provider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { ReadStream } from 'fs';
2-
import { Injectable, NotFoundException } from '@nestjs/common';
2+
import { Injectable, NotFoundException, OnModuleDestroy } from '@nestjs/common';
33
import { LogFile } from 'src/modules/profiler/models/log-file';
44
import ERROR_MESSAGES from 'src/constants/error-messages';
55

66
@Injectable()
7-
export class LogFileProvider {
7+
export class LogFileProvider implements OnModuleDestroy {
88
private profilerLogFiles: Map<string, LogFile> = new Map();
99

1010
/**
@@ -47,4 +47,8 @@ export class LogFileProvider {
4747

4848
return { stream, filename: logFile.getFilename() };
4949
}
50+
51+
async onModuleDestroy() {
52+
await Promise.all(Array.from(this.profilerLogFiles.values()).map((logFile: LogFile) => logFile.destroy()));
53+
}
5054
}

redisinsight/api/src/modules/profiler/providers/profiler-client.provider.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
import { get } from 'lodash';
12
import { Socket } from 'socket.io';
23
import { Injectable } from '@nestjs/common';
34
import { ProfilerClient } from 'src/modules/profiler/models/profiler.client';
45
import { ClientLogsEmitter } from 'src/modules/profiler/emitters/client.logs-emitter';
56
import { MonitorSettings } from 'src/modules/profiler/models/monitor-settings';
67
import { LogFileProvider } from 'src/modules/profiler/providers/log-file.provider';
8+
import { InstancesBusinessService } from 'src/modules/shared/services/instances-business/instances-business.service';
79

810
@Injectable()
911
export class ProfilerClientProvider {
1012
private profilerClients: Map<string, ProfilerClient> = new Map();
1113

1214
constructor(
1315
private logFileProvider: LogFileProvider,
16+
private instancesBusinessService: InstancesBusinessService,
1417
) {}
1518

1619
async getOrCreateClient(socket: Socket, settings: MonitorSettings): Promise<ProfilerClient> {
@@ -21,9 +24,11 @@ export class ProfilerClientProvider {
2124
if (settings?.logFileId) {
2225
const profilerLogFile = await this.logFileProvider.getOrCreate(settings.logFileId);
2326

24-
// // set database alias as part of the log file name
25-
// const alias = (await this.instancesBusinessService.getOneById(instanceId)).name;
26-
// profilerLogFile.setAlias(alias);
27+
// set database alias as part of the log file name
28+
const alias = (await this.instancesBusinessService.getOneById(
29+
get(socket, 'handshake.query.instanceId'),
30+
)).name;
31+
profilerLogFile.setAlias(alias);
2732

2833
clientObserver.addLogsEmitter(await profilerLogFile.getEmitter());
2934
}

0 commit comments

Comments
 (0)