Skip to content

[Scheduler] Add debug:scheduler command #49802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Korbeil
Copy link
Contributor

@Korbeil Korbeil commented Mar 24, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
License MIT
Doc PR N/A

Add a debug:scheduler command that allows:

  • Listing schedules for the default Scheduler
$ bin/console debug:scheduler

Information for Scheduler "default"
===================================

 ------------------------------- --------------------------------------------------------- --------------------------- 
  Message                         Trigger type                                              Next run date              
 ------------------------------- --------------------------------------------------------- --------------------------- 
  App\Message\OneMonthMessage     Symfony\Component\Scheduler\Trigger\DateIntervalTrigger   2023-03-24T18:43:37+01:00  
  App\Message\TwoMinutesMessage   Symfony\Component\Scheduler\Trigger\DateIntervalTrigger   2023-03-24T18:43:37+01:00  
 ------------------------------- --------------------------------------------------------- --------------------------- 

  • Listing schedules for a Scheduler you choose
$ bin/console debug:scheduler default

Information for Scheduler "default"
===================================

 ------------------------------- --------------------------------------------------------- --------------------------- 
  Message                         Trigger type                                              Next run date              
 ------------------------------- --------------------------------------------------------- --------------------------- 
  App\Message\OneMonthMessage     Symfony\Component\Scheduler\Trigger\DateIntervalTrigger   2023-03-24T18:43:41+01:00  
  App\Message\TwoMinutesMessage   Symfony\Component\Scheduler\Trigger\DateIntervalTrigger   2023-03-24T18:43:41+01:00  
 ------------------------------- --------------------------------------------------------- --------------------------- 
  • Error when giving a Scheduler that doesn't exists (and give you available schedulers)
$ bin/console debug:scheduler foo

                                                                                                                        
 [ERROR] The "foo" scheduler could not be found. Available schedulers: default.                                         
                                                                                                                        
  • Filter for a Scheduler on certain messages only
$ bin/console debug:scheduler default OneMonthMessage

Information for Scheduler "default"
===================================

 // Displaying only 'OneMonthMessage' messages                                                                          

 ----------------------------- --------------------------------------------------------- --------------------------- 
  Message                       Trigger type                                              Next run date              
 ----------------------------- --------------------------------------------------------- --------------------------- 
  App\Message\OneMonthMessage   Symfony\Component\Scheduler\Trigger\DateIntervalTrigger   2023-03-24T18:44:06+01:00  
 ----------------------------- --------------------------------------------------------- ---------------------------
  • Choose from which time the next run date should be calculated
$ bin/console debug:scheduler default --from="2025-04-20 08:00:00" --from-format="Y-m-d H:i:s" --from-timezone="America/Curacao"

Information for Scheduler "default"
===================================

------------------------------- --------------------------------------------------------- --------------------------- 
 Message                         Trigger type                                              Next run date              
------------------------------- --------------------------------------------------------- --------------------------- 
 App\Message\OneMonthMessage     Symfony\Component\Scheduler\Trigger\DateIntervalTrigger   2025-04-24T12:55:07-04:00  
 App\Message\TwoMinutesMessage   Symfony\Component\Scheduler\Trigger\DateIntervalTrigger   2025-04-20T08:01:07-04:00  
------------------------------- --------------------------------------------------------- --------------------------- 
  • Show details about used lock & state (very small information for now, could be enriched later)
$ bin/console debug:scheduler --show-lock

Information for Scheduler "default"
===================================

 // Displaying only Scheduler Lock information                                                                          

 ! [NOTE] No lock found on given Scheduler                                                                              

$ bin/console debug:scheduler --show-state

Information for Scheduler "default"
===================================

 // Displaying only Scheduler Cache information                                                                         

 Using "Symfony\Component\Cache\Adapter\ArrayAdapter" cache adapter

@carsonbot carsonbot added this to the 6.3 milestone Mar 24, 2023
@Korbeil Korbeil force-pushed the feature/add-scheduler-debug-command branch from b07e419 to d77c3d5 Compare March 24, 2023 21:46
@Korbeil Korbeil force-pushed the feature/add-scheduler-debug-command branch from d77c3d5 to b2337a4 Compare March 24, 2023 21:55
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Command;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better to move this code into the scheduler component?

@kbond
Copy link
Member

kbond commented Mar 25, 2023

Duplicate of #49795 :)

@Korbeil
Copy link
Contributor Author

Korbeil commented Mar 25, 2023

Closing in favor of @kbond PR.
Will do another PR to add some features to its PR later.

@Korbeil Korbeil closed this Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants