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

Question: What is the right way to initiate a cron job once at boot and then on the cron schedule? #226

Open
hms opened this issue May 16, 2024 · 1 comment

Comments

@hms
Copy link

hms commented May 16, 2024

I have several cron jobs. Because I'm currently locked to Heroku, there are times when I'm not in control of when my application is running or gets restarted. To that end, in the case of missing the window for a daily / periodic Cron execution, I use a Rails.application.after_initialization block to run these jobs once at SolidQueue boot.

Is this the right way / Is there a better way?

Thanks in advance.

@rosa
Copy link
Member

rosa commented May 28, 2024

Hmm... I never had this need so I'm not completely sure, but that sounds right to me. Maybe this could be a future enhancement: on start, check if the last run of every recurring task happened, and if not, enqueue one 🤔 Though it'd be a little brittle, depending on how often restarts happen and your preservation period for finished jobs.

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

No branches or pull requests

2 participants