Skip to content
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

Dynamic creation of CronEntries #1457

Closed
vArdashev opened this issue Aug 5, 2024 · 2 comments
Closed

Dynamic creation of CronEntries #1457

vArdashev opened this issue Aug 5, 2024 · 2 comments

Comments

@vArdashev
Copy link

Hello and thanks for the cool gem.
In my project, the user can add new cron tasks and delete old ones. GoodJob::CronEntry has methods for enabling/disabling tasks, but it looks like new tasks can only be added at the rails initialization stage.
Is it possible to dynamically add/remove new tasks for cron? I see that the list of cron tasks can be reinitialized by restarting GoodJob::CronManager. Could you describe the correct way to update the cron task list in runtime?
GoodJob is running in external mode with multiple processes and multiple rails backends.

@bensheldon
Copy link
Owner

Is it possible to dynamically add/remove new tasks for cron?

It's not intended. The analogous design is the system crontab: it's unlikely an application would be designed around updating it.

Why do you want to update it dynamically? My general suggestion for folks is that if there is an application feature for users to schedule things, build tracking those tasks (when should they run, when did they last run) at the application layer, and then have a GoodJob cron entry that runs every hour (or 15 minutes, or minute) that then queries those records. That will scale much better and be easier to track/cancel/update than reaching into GoodJob's internals that could change.

@vArdashev
Copy link
Author

Thank you for your feedback. You are right, the current approach is not the most efficient architectural solution. This issue arose when we were porting an older solution from Sidekiq, which allowed for these types of workarounds.
A good reason to improve the architecture)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants