SchedulerBundle icon indicating copy to clipboard operation
SchedulerBundle copied to clipboard

How do you 'refresh' your scheduled tasks when you make a change to the scheduler.yaml?

Open mmjr-x opened this issue 1 year ago • 1 comments

@Guikingone First of all thank you for your great work and your amazing bundle! :)

We are currently using your bundle however we are running into the issue that whenever we make a change to the scheduler.yaml (in our case specifically changing the expression of a task) that the scheduled task is not updated in our _symfony_scheduler_tasks database table.

We hypothesized that it might be the case that the tasks first has have to been executed and afterwards its configuration is refreshed, however after some testing this also did not seem to be the case.

I tried studying the documentation however however aside from rebooting the scheduler using bin/console scheduler:reboot we found the only way to have it refresh task from the updated configuration of the scheduler.yaml is to delete the database entry for that task. Afterwards it will get readded on the next bin/console scheduler:consume (we run this in a cron every minute).

Sadly we can't use scheduler:reboot since we have both a mix of programmatically scheduled tasks and tasks scheduled via the scheduler.yaml configuration (using scheduler:reboot also removes all programmatically scheduled tasks which cant be easily rescheduled).

First of al I am wondering if what we are seeing is the intended behavior, if this is due to a configuration mistake on our end or perhaps a bug to some extend?

Second I would like to know if there is some workaround, or configuration we can do to either have it update automatically or if there is some way to exclude certain scheduled tasks (in our case the programmatically set up ones) from the scheduler:reboot?

Some additional info about our setup:

  • php 8.1
  • Symfony 6.3
  • guikingone/scheduler-bundle 0.10.*
  • Excempt from our scheduler.yaml (does not include all tasks and some names where changed for privacy reasons):
scheduler_bundle:
  transport:
    dsn: 'doctrine://default?execution_mode=first_in_first_out'
  tasks:
    import_run_x1:
      type: 'command'
      command: 'app:import:run'
      arguments: ['1', '1']
      expression: '0 3 * * *'
      description: 'Runs the type 1 import for x1'
    import_run_x2:
      type: 'command'
      command: 'app:import:run'
      arguments: ['1', '2']
      expression: '0 2 * * *'
      description: 'Runs the type 1 import for x2'

If you could offer any help or advice on this issue it would be much appreciated! :)

mmjr-x avatar Jul 26 '23 08:07 mmjr-x