0

I am planning to write a script for a Rails app that will be constantly running and needs access to the ActiveRecord instance.

I've looked into Sidekiq and Resque but am not quite sure which tool is best for the job (access to ActiveRecord and constantly running in the background asynchronously from the main application).

Also, after reading about Sidekiq / Resque, I believe that those two solutions may be too heavyweight for what I want to do ( add some data to ActiveRecord ).

Anybody have experience with this?

Any help or tips would be appreciated. Thanks.

Delos Chang
  • 1,823
  • 3
  • 27
  • 47

1 Answers1

2

I defined a class to run rufus-scheduled job, I use a rake task to run this class, then use foreman to define a job in Procfile, and export to upstart (http://michael.vanrooijen.io/articles/2011/06/08-managing-and-monitoring-your-ruby-application-with-foreman-and-upstart/)

class XXXX
  def initialize
    @scheduler = Rufus::Scheduler.start_new
  end

  def run

    @scheduler.every '120s' do
      #run code
    end


    @scheduler.join


  end
end


task :rake_task => :environment do
  require "class file path"
  obj = XXXX.new
  obj.run

end

In Procfile

background_jobs:      rake rake_task
McGar
  • 205
  • 1
  • 10