nestjs/schedule

Feature request: Add an option to disable all schedule job when registering module.

michael-land opened this issue · 1 comments

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

What is the motivation / use case for changing the behavior?

We have a lot of tasks running with nestjs schedule via @Cron(CronExpression). I hope there is an option to disabled all cronjob/interval/timeout when registering module via ScheduleModule.forRoot({ enabled: this.configService.isProd() }). it would make development and debug specific job easier.

Or is there alternative to run specific job only during development?

Also, it would be nice we can pass default time zone via ScheduleModule.forRoot(), so user can skip pass them everytime via @Cron(CronExpression,{ timeZone: ""})

I hope there is an option to disabled all cronjob/interval/timeout when registering module

Create a Dynamic Module which conditionally imports the ScheduleModule. nI case you don't want to register any cron jobs/intervals/timeouts, simply don't register the module.