File tree 3 files changed +12
-2
lines changed
3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -39,3 +39,6 @@ TRAKT_KEY=
39
39
40
40
# The time between cronjobs.
41
41
CRON_TIME = ' 0 0 3 * * *'
42
+
43
+ # Should the scraper start scraping on start
44
+ SCRAPE_ON_START = false
Original file line number Diff line number Diff line change @@ -51,14 +51,18 @@ export class ScraperModule implements OnApplicationBootstrap {
51
51
private providersService : ProvidersService
52
52
53
53
public onApplicationBootstrap ( ) : void {
54
- const job = new CronJob ( this . configService . get ( ' CRON_TIME' ) , ( ) => {
54
+ const job = new CronJob ( this . configService . get ( ConfigService . CRON_TIME ) , ( ) => {
55
55
this . scrapeConfigs ( )
56
56
} )
57
57
58
58
this . schedulerRegistry . addCronJob ( ScraperModule . JOB_NAME , job )
59
59
job . start ( )
60
60
61
- this . logger . log ( `Enabled cron on '${ this . configService . get ( 'CRON_TIME' ) } '` )
61
+ this . logger . log ( `Enabled cron on '${ this . configService . get ( ConfigService . CRON_TIME ) } '` )
62
+
63
+ if ( this . configService . get ( ConfigService . SCRAPE_ON_START ) ) {
64
+ this . scrapeConfigs ( )
65
+ }
62
66
}
63
67
64
68
private async scrapeConfigs ( ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export class ConfigService {
15
15
public static readonly MONGO_PORT : string = 'MONGO_PORT'
16
16
public static readonly MONGO_DATABASE : string = 'MONGO_DATABASE'
17
17
public static readonly CRON_TIME : string = 'CRON_TIME'
18
+ public static readonly SCRAPE_ON_START : string = 'SCRAPE_ON_START'
18
19
public static readonly TRAKT_KEY : string = 'TRAKT_KEY'
19
20
public static readonly TMDB_KEY : string = 'TMDB_KEY'
20
21
public static readonly TVDB_KEY : string = 'TVDB_KEY'
@@ -109,6 +110,8 @@ export class ConfigService {
109
110
110
111
[ ConfigService . FANART_KEY ] : Joi . string ( )
111
112
. required ( ) ,
113
+
114
+ [ ConfigService . SCRAPE_ON_START ] : Joi . boolean ( )
112
115
} )
113
116
114
117
const { error, value : validatedEnvConfig } = envVarsSchema . validate ( envConfig , { stripUnknown : true } )
You can’t perform that action at this time.
0 commit comments