Browse Source

Feature/expose ENABLE_FEATURE_CRON environment variable (#7090)

* Expose ENABLE_FEATURE_CRON environment variable

* Update changelog
pull/7076/head
Thomas Kaul 7 days ago
committed by GitHub
parent
commit
1896289bc9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      CHANGELOG.md
  2. 1
      apps/api/src/services/configuration/configuration.service.ts
  3. 49
      apps/api/src/services/cron/cron.module.ts
  4. 1
      apps/api/src/services/interfaces/environment.interface.ts

4
CHANGELOG.md

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Exposed the `ENABLE_FEATURE_CRON` environment variable to control scheduled cron job execution
### Changed
- Improved the language localization for German (`de`)

1
apps/api/src/services/configuration/configuration.service.ts

@ -43,6 +43,7 @@ export class ConfigurationService {
ENABLE_FEATURE_AUTH_GOOGLE: bool({ default: false }),
ENABLE_FEATURE_AUTH_OIDC: bool({ default: false }),
ENABLE_FEATURE_AUTH_TOKEN: bool({ default: true }),
ENABLE_FEATURE_CRON: bool({ default: true }),
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
ENABLE_FEATURE_GATHER_NEW_EXCHANGE_RATES: bool({ default: true }),
ENABLE_FEATURE_READ_ONLY_MODE: bool({ default: false }),

49
apps/api/src/services/cron/cron.module.ts

@ -1,12 +1,19 @@
import { UserModule } from '@ghostfolio/api/app/user/user.module';
import { UserService } from '@ghostfolio/api/app/user/user.service';
import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module';
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.module';
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service';
import { PropertyModule } from '@ghostfolio/api/services/property/property.module';
import { PropertyService } from '@ghostfolio/api/services/property/property.service';
import { DataGatheringQueueModule } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.module';
import { DataGatheringService } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.service';
import { StatisticsGatheringQueueModule } from '@ghostfolio/api/services/queues/statistics-gathering/statistics-gathering.module';
import { StatisticsGatheringService } from '@ghostfolio/api/services/queues/statistics-gathering/statistics-gathering.service';
import { TwitterBotModule } from '@ghostfolio/api/services/twitter-bot/twitter-bot.module';
import { TwitterBotService } from '@ghostfolio/api/services/twitter-bot/twitter-bot.service';
import { Module } from '@nestjs/common';
import { Logger, Module } from '@nestjs/common';
import { CronService } from './cron.service';
@ -20,6 +27,44 @@ import { CronService } from './cron.service';
TwitterBotModule,
UserModule
],
providers: [CronService]
providers: [
{
inject: [
ConfigurationService,
DataGatheringService,
ExchangeRateDataService,
PropertyService,
StatisticsGatheringService,
TwitterBotService,
UserService
],
provide: CronService,
useFactory: (
configurationService: ConfigurationService,
dataGatheringService: DataGatheringService,
exchangeRateDataService: ExchangeRateDataService,
propertyService: PropertyService,
statisticsGatheringService: StatisticsGatheringService,
twitterBotService: TwitterBotService,
userService: UserService
) => {
if (!configurationService.get('ENABLE_FEATURE_CRON')) {
Logger.log('Scheduled cron jobs are disabled', 'CronService');
return null;
}
return new CronService(
configurationService,
dataGatheringService,
exchangeRateDataService,
propertyService,
statisticsGatheringService,
twitterBotService,
userService
);
}
}
]
})
export class CronModule {}

1
apps/api/src/services/interfaces/environment.interface.ts

@ -19,6 +19,7 @@ export interface Environment extends CleanedEnvAccessors {
ENABLE_FEATURE_AUTH_GOOGLE: boolean;
ENABLE_FEATURE_AUTH_OIDC: boolean;
ENABLE_FEATURE_AUTH_TOKEN: boolean;
ENABLE_FEATURE_CRON: boolean;
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
ENABLE_FEATURE_GATHER_NEW_EXCHANGE_RATES: boolean;
ENABLE_FEATURE_READ_ONLY_MODE: boolean;

Loading…
Cancel
Save