mirror of
https://github.com/CaramelFur/Picsur.git
synced 2025-11-16 16:25:49 +01:00
Fix demo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Module, OnModuleInit } from '@nestjs/common';
|
||||
import { Logger, Module, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
||||
import { ImageDBModule } from '../../collections/imagedb/imagedb.module';
|
||||
import Config from '../../env';
|
||||
import { DemoManagerService } from './demomanager.service';
|
||||
@@ -7,14 +7,25 @@ import { DemoManagerService } from './demomanager.service';
|
||||
imports: [ImageDBModule],
|
||||
providers: [DemoManagerService],
|
||||
})
|
||||
export class DemoManagerModule implements OnModuleInit {
|
||||
export class DemoManagerModule implements OnModuleInit, OnModuleDestroy {
|
||||
private readonly logger = new Logger('DemoManagerModule');
|
||||
|
||||
constructor(private readonly demoManagerService: DemoManagerService) {}
|
||||
|
||||
private interval: NodeJS.Timeout;
|
||||
|
||||
onModuleInit() {
|
||||
if (Config.demo.enabled) {
|
||||
setInterval(this.demoManagerService.execute, Config.demo.interval);
|
||||
this.logger.log('Demo mode enabled');
|
||||
|
||||
this.interval = setInterval(
|
||||
this.demoManagerService.execute.bind(this.demoManagerService),
|
||||
Config.demo.interval,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onModuleDestroy() {
|
||||
if (this.interval) clearInterval(this.interval);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user