Aditya
Aditya

Reputation: 123

does Delayed_job daemon not run in development?

I'm using delayed_job and I am able to run jobs using rake jobs:work but using the daemonized version, it does nothing although I see it in the process list.

I'm using:

I'm running delayed_job using:

unix>RAILS_ENV=development script/delayed_job start

Upvotes: 5

Views: 4839

Answers (2)

Gray Kemmey
Gray Kemmey

Reputation: 1002

It could be a problem loading a custom job class file. To test that, try this:

  • Enter the rails console rails console --sandbox.
  • Make sure you have a job in the table job = Delayed::Job.first.
  • Try YAML.load(job.handler). If you get an error that looks like this: ArgumentError: undefined class/module MyCustomClass, it's probably a problem loading your custom job
  • Still in the rails console, run require 'My_Custom_Class. Then run the YAML.load(job.handler) command again. If this returns the appropriate object it's definitely a class loading problem.

To fix the problem create the file config/initializers/custom.rb and in it put require 'My_Custom_Class'.

You should then be able to run rake jobs::workoff and get something that looks like this:

[Worker(host:my.host pid:5085)] Starting job worker
[Worker(host:my.host pid:5085)] MyCustomJob completed after 0.0774
[Worker(host:my.host pid:5085)] 1 jobs processed at 9.1935 j/s, 0 failed ...
[Worker(host:my.host pid:5085)] No more jobs available. Exiting

Upvotes: 4

Ernest
Ernest

Reputation: 8829

To answer your question we may need more information.

Are jobs added to database? Are there any errors in jobs?

What's the result of RAILS_ENV=development script/delayed_job status as I already mentioned?

Second, did you went through the most common problems Wiki page?

https://github.com/collectiveidea/delayed_job/wiki/Common-problems

Upvotes: 3

Related Questions