client cleanup

This commit is contained in:
Ben Wilson
2023-08-04 16:40:52 -04:00
parent f85967daf8
commit d4bbd9ebef
2 changed files with 16 additions and 16 deletions
+10 -10
View File
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm'; import { IsNull, LessThan, Repository } from 'typeorm';
import { ClientEntity } from './client.entity'; import { ClientEntity } from './client.entity';
@@ -17,16 +17,16 @@ export class ClientService {
} }
// public async killDeadClients(){ public async killDeadClients() {
// var tenMinutes = new Date(new Date().getTime() - (60 * 60 * 1000)); var tenMinutes = new Date(new Date().getTime() - (60 * 60 * 1000));
// return await this.clientRepository.update({ return await this.clientRepository.update({
// deletedAt: IsNull(), deletedAt: IsNull(),
// updatedAt: LessThan(tenMinutes) updatedAt: LessThan(tenMinutes)
// }, { }, {
// deletedAt: new Date() deletedAt: new Date()
// }); });
// } }
public async heartbeat(address: string, clientName: string, sessionId: string) { public async heartbeat(address: string, clientName: string, sessionId: string) {
return await this.clientRepository.update({ address, clientName, sessionId }, { deletedAt: null, updatedAt: new Date() }); return await this.clientRepository.update({ address, clientName, sessionId }, { deletedAt: null, updatedAt: new Date() });
+6 -6
View File
@@ -36,11 +36,11 @@ export class AppService implements OnModuleInit {
} }
} }
// @Cron(CronExpression.EVERY_10_MINUTES) @Cron(CronExpression.EVERY_10_MINUTES)
// private async killDeadClients() { private async killDeadClients() {
// if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') { if (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0') {
// await this.clientService.killDeadClients(); await this.clientService.killDeadClients();
// } }
// } }
} }