Ruby on Rails Delayed Job Local Wont Run

I am working with a deferred task for an active gem entry https://github.com/collectiveidea/delayed_job I am trying to set up work five minutes after the event takes place in my application. Five minutes later I need to do some database updates. I tried rake: work and RAILS_ENV = development script / delayed_job start. Before that, I started a batch installation, the rails generated delayed_job: active_record and rake db: migrate. I have a lottery site that needs to check winners every five minutes and update tokens for winning players.

I wait five minutes, but no updates are made in my local application.

Here is what I still have:

Gem File:

gem 'delayed_job_active_record' gem "daemons" 

Task (located in lib)

 class WinnersJob < Struct.new(:blast_id) def perform ... end 

Controller

  require 'winners' Delayed::Job.enqueue(WinnersJob.new(blast.id), 1, 5.minutes.from_now) end 
+2
source share
1 answer

I think you should run background workers locally using a wizard. The following worked on my Mac.

From Heroku docs:

Then you need to tell your application to process the jobs placed in the job queue, you can do this by adding this to your Procfile :

 worker: bundle exec rake jobs:work 

Now, when you launch the application using Foreman, it will begin processing your job queue.

 foreman start 

Having said all this, if you are not deploying to a Mac, it doesn't really matter if they run locally. (I noticed this after , I got it working.) This only matters if it works on your servers. If you are deploying to Heroku, then the Delayed Job works well.

Link:

https://devcenter.heroku.com/articles/delayed-job
https://devcenter.heroku.com/articles/procfile

+8
source

All Articles