Ruby on Rails - Job Delay - Job Queue is not added to the database
The delayed_jobs table is not added to the job queue when it is daemonized. But it works when it is not demonized.
I have three rake tasks (a.rake, b.rake, c.rake).
In a.rake
task :run_a => :environment do
A.new.get_a_data
end
class A
def get_a_data
...
schedule_next_a_job
end
def schedule_next_a_job
get_a_data
end
handle_asynchronously :get_a_data, :run_at => Proc.new { 2.minutes.from_now }, :queue => 'a'
end
In b.rake
task :run_b => :environment do
B.new.get_b_data
end
class B
def get_b_data
...
schedule_next_b_job
end
def schedule_next_b_job
get_b_data
end
handle_asynchronously :get_b_data, :run_at => Proc.new { 5.minutes.from_now }, :queue => 'b'
end
In c.rake
namespace :run do
task :start do
`rake run_a`
`rake run_b`
if Rails.env == 'development'
`QUEUES=a,b rake jobs:work`
else
`RAILS_ENV=production bin/delayed_job --queues=a,b start`
end
task :stop do
`rake jobs:clear`
end
end
In the console, I run as shown below:
RAILS_ENV=production rake run:start # to start jobs worker
rake run:stop # to clear my jobs worker
In my table of slowed down jobs, last_error shows how:
Failed to load job: undefined class / module A
Load failed: undefined class / module B
Can anyone help me get rid of this problem?
Thanks in Advance.
+3
source to share