Rails Cron Job
Hi Folks,
Project ID: whenever
web: bundle exec rake db:migrate && bundle exec rails server -p ${PORT:-3000}
worker: bundle exec whenever --update-crontab
bundle exec rake task```. This works well. However, it seems like every time the cron job runs, it rebuilds everything from scratch, which sometimes takes a long time. Is this expected, or could it be optimized with build caching?
Thank you.
5 Replies
Project ID:
d6496119-3fda-4ccf-ba26-1050b4d6d823
I believe this is expected, unfortunately. Could you instead run the job on a cron schedule in-app?
As in, run the app 24/7, offload as much memory as you can, then run your job using a cron scheduling package
Thank you for your suggestion.
I'm interested in the idea of running the cron job within the app itself, but could you clarify what you mean by an "in-app cron schedule"?
Are you suggesting the use of a specific Ruby gem or library for this purpose?
I'm not a Ruby dev, but yes. In Python for example, you would use the package
schedule
also like to note that railway's procfile does not support worker tasks, you should use a seprate railway service just for a worker type task