zenstruck/schedule-bundle

Task hot disabling and other capabilities

Closed this issue · 2 comments

Hello! Thanks for sharing this bundle, hope I find it useful in my projects
But for now, I have some questions that haunt me.

  1. What I need to do in case I want to disable a certain task immediately? Change source code and redeploy app?
  2. Is there a way to find out that some task is running right now?
    For example, while deploying I could use this information and wait until the task will be finished, and only then update the app
  3. Does task lock have some timeout? After that, it will be automatically released, cause some infinitive loop or network problems could lock that task forever
  4. Is there a way to get a list of all tasks not from CLI but show in admin area at least for information purposes

Thanks once again

kbond commented

Hey!

  1. No way out of the box, redeploying is the only way. You could rig something custom up with either events or a custom extension that skips the task under certain conditions.
  2. No, again you'd have to create something custom. In my app, I detect if the the app is deploying and skip running the schedule if it is. This only stops new tasks from starting however.
  3. You can pass a TTL to $task->withoutOverlapping()/onSingleServer(). I'm not really familiar with symfony/lock but I believe the lock auto-expires if it's not released after that time.
  4. Again, not out of the box but I created a full admin interface for my schedule pretty easily: create a controller and inject ScheduleRunner, then call $scheduleRunner->buildSchedule()->all() to get all the available Task objects.

Hope this helps!

Thank you very much, I'll give it a try!