space out system queue tasks to not crush the instance all at once

This commit is contained in:
Hazelnoot 2025-06-26 10:55:30 -04:00
parent c5bbd667a7
commit edcaef0727
3 changed files with 11 additions and 11 deletions

View file

@ -80,7 +80,7 @@ export class QueueService implements OnModuleInit {
public async onModuleInit() {
await this.systemQueue.upsertJobScheduler(
'tickCharts-scheduler',
{ pattern: '55 * * * *' },
{ pattern: '0 * * * *' },
{
name: 'tickCharts',
opts: {
@ -91,7 +91,7 @@ export class QueueService implements OnModuleInit {
await this.systemQueue.upsertJobScheduler(
'resyncCharts-scheduler',
{ pattern: '0 0 * * *' },
{ pattern: '10 0 * * *' },
{
name: 'resyncCharts',
opts: {
@ -102,7 +102,7 @@ export class QueueService implements OnModuleInit {
await this.systemQueue.upsertJobScheduler(
'cleanCharts-scheduler',
{ pattern: '0 0 * * *' },
{ pattern: '30 0 * * *' },
{
name: 'cleanCharts',
opts: {
@ -113,7 +113,7 @@ export class QueueService implements OnModuleInit {
await this.systemQueue.upsertJobScheduler(
'aggregateRetention-scheduler',
{ pattern: '0 0 * * *' },
{ pattern: '0 1 * * *' },
{
name: 'aggregateRetention',
opts: {
@ -124,7 +124,7 @@ export class QueueService implements OnModuleInit {
await this.systemQueue.upsertJobScheduler(
'clean-scheduler',
{ pattern: '0 0 * * *' },
{ pattern: '15 1 * * *' },
{
name: 'clean',
opts: {
@ -146,7 +146,7 @@ export class QueueService implements OnModuleInit {
await this.systemQueue.upsertJobScheduler(
'backBufferedReactions-scheduler',
{ pattern: '0 0 * * *' },
{ pattern: '30 1 * * *' },
{
name: 'backBufferedReactions',
opts: {
@ -158,7 +158,7 @@ export class QueueService implements OnModuleInit {
await this.systemQueue.upsertJobScheduler(
'checkModeratorsActivity-scheduler',
// 毎時30分に起動
{ pattern: '30 * * * *' },
{ pattern: '45 1 * * *' },
{
name: 'checkModeratorsActivity',
opts: {

View file

@ -83,7 +83,7 @@ export class AggregateRetentionProcessorService {
const data = deepClone(record.data);
data[dateKey] = retention;
this.retentionAggregationsRepository.update(record.id, {
await this.retentionAggregationsRepository.update(record.id, {
updatedAt: now,
data,
});

View file

@ -45,13 +45,13 @@ export class CleanProcessorService {
public async process(): Promise<void> {
this.logger.info('Cleaning...');
this.userIpsRepository.delete({
await this.userIpsRepository.delete({
createdAt: LessThan(new Date(this.timeService.now - (1000 * 60 * 60 * 24 * 90))),
});
// 使われてないアンテナを停止
if (this.config.deactivateAntennaThreshold > 0) {
this.antennasRepository.update({
await this.antennasRepository.update({
lastUsedAt: LessThan(new Date(this.timeService.now - this.config.deactivateAntennaThreshold)),
}, {
isActive: false,
@ -69,7 +69,7 @@ export class CleanProcessorService {
});
}
this.reversiService.cleanOutdatedGames();
await this.reversiService.cleanOutdatedGames();
this.logger.info('Cleaned.');
}