From 37b92329ba66d1c9c76596eb028a3dd23ad7187d Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 30 Nov 2023 23:50:13 -0500 Subject: [PATCH] change cron to interval --- src/services/app.service.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/services/app.service.ts b/src/services/app.service.ts index 4ac9008..6581df8 100644 --- a/src/services/app.service.ts +++ b/src/services/app.service.ts @@ -1,5 +1,5 @@ import { Injectable, OnModuleInit } from '@nestjs/common'; -import { Cron, CronExpression } from '@nestjs/schedule'; +import { Interval } from '@nestjs/schedule'; import { DataSource } from 'typeorm'; import { ClientStatisticsService } from '../ORM/client-statistics/client-statistics.service'; @@ -29,8 +29,9 @@ export class AppService implements OnModuleInit { await this.dataSource.query(`PRAGMA mmap_size = 3000000000;`); } - @Cron(CronExpression.EVERY_HOUR) + @Interval(1000 * 60 * 60) private async deleteOldStatistics() { + console.log('Deleting statistics'); if (process.env.ENABLE_SOLO == 'true' && (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0')) { const deletedStatistics = await this.clientStatisticsService.deleteOldStatistics(); console.log(`Deleted ${deletedStatistics.affected} old statistics`); @@ -39,10 +40,12 @@ export class AppService implements OnModuleInit { } } - @Cron(CronExpression.EVERY_5_MINUTES) + @Interval(1000 * 60 * 5) private async killDeadClients() { + console.log('Killing dead clients'); if (process.env.ENABLE_SOLO == 'true' && (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0')) { await this.clientService.killDeadClients(); } } + } \ No newline at end of file