Best current rails background task method?

后端 未结 3 456
醉话见心
醉话见心 2021-02-08 01:11

I am trying to find out the best way to run scripts in the background. I have been looking around and found plenty of options, but many/most seem to have become inactive in the

相关标签:
3条回答
  • 2021-02-08 01:51

    I think you're looking for a background job queuing system.

    For that, you're either looking for resque or delayed_job. Both support scheduling tasks at some point in the future -- delayed_job does this natively, whereas resque has a plugin for it called resque_scheduler.

    You would enqueue jobs in the background with parameters that you specify, and then at the time you selected they'll be executed. You can set jobs to recur indefinitely or a fixed number of times (at least with resque-scheduler, not sure about delayed_job).

    delayed_job is easier to set up since it saves everything in the database. resque is more robust but requires you to have redis in your stack -- but if you do already it's pretty much the ideal solution for your problem.

    0 讨论(0)
  • 2021-02-08 01:52

    Take a look at the gem whenever at https://github.com/javan/whenever.

    It allows you to schedule tasks like cron jobs.

    Works very well under linux, and the last commit was 14 days ago. A friend of mine used it in a project and was pretty satisfied with it.

    edit: take a look at the gem delayed_job as well, it is good for executing long tasks in the background. Useful when creating a cron job only to start other tasks.

    0 讨论(0)
  • 2021-02-08 02:18

    I recently learned about Sidekiq, and I think it is really great.

    There's also a RailsCast about it - Sidekiq.

    0 讨论(0)
提交回复
热议问题