mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
change cron to interval
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||||
import { Cron, CronExpression } from '@nestjs/schedule';
|
import { Interval } from '@nestjs/schedule';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
|
|
||||||
import { ClientStatisticsService } from '../ORM/client-statistics/client-statistics.service';
|
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;`);
|
await this.dataSource.query(`PRAGMA mmap_size = 3000000000;`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cron(CronExpression.EVERY_HOUR)
|
@Interval(1000 * 60 * 60)
|
||||||
private async deleteOldStatistics() {
|
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')) {
|
if (process.env.ENABLE_SOLO == 'true' && (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0')) {
|
||||||
const deletedStatistics = await this.clientStatisticsService.deleteOldStatistics();
|
const deletedStatistics = await this.clientStatisticsService.deleteOldStatistics();
|
||||||
console.log(`Deleted ${deletedStatistics.affected} old statistics`);
|
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() {
|
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')) {
|
if (process.env.ENABLE_SOLO == 'true' && (process.env.NODE_APP_INSTANCE == null || process.env.NODE_APP_INSTANCE == '0')) {
|
||||||
await this.clientService.killDeadClients();
|
await this.clientService.killDeadClients();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user