Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script/delayed_job background process immediately dies silently #1084

Closed
gchiaren opened this issue Mar 19, 2019 · 6 comments
Closed

script/delayed_job background process immediately dies silently #1084

gchiaren opened this issue Mar 19, 2019 · 6 comments

Comments

@gchiaren
Copy link

gchiaren commented Mar 19, 2019

This is in development. It seems delayed job immediately dies as soon as I start it, and fails silently without writing anything to the log (that's the most frustrating part bc I'm completely stuck). Below are more details:

I start DJ in the console using script/delayed_job start. The PID file is created, but when I do a script/delayed_job status it says:

pid-file for killed process 47552 found (/Users/me/Rails/projects/tmp/pids/delayed_job.pid), deleting.
delayed_job: no instances running

Sure enough, the jobs in the database table just sit there, with the first one up getting its locked_at timestamp set.

My DJ log file only logs the attempted start, but nothing about the stop. It just says:

Starting job worker
Job job_name (id=1537) RUNNING

I followed the instructions in Common Problems to no avail. If I manually run rake jobs:work the jobs are indeed processed and disappear from the db.

I thought it might be a serialization problem, but I can do this successfully from the console:

j = Delayed::Job.last
YAML.load(j.handler)

Versions of everything:

  • Rails (3.2.22)
  • Ruby (2.2.10)
  • delayed_job (4.1.5)
  • delayed_job_active_record (4.1.3)
  • daemons (1.3.1)

My DJ config looks like this:

Delayed::Worker.max_attempts = 5
Delayed::Worker.max_run_time = 5.minutes
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))
Delayed::Worker.destroy_failed_jobs = false
@dignoe
Copy link

dignoe commented May 30, 2019

@gchiaren Did you ever resolve this? The same thing is happening to me.

@gchiaren
Copy link
Author

@dignoe Nope! But I had to handle it somehow so I'm using bluepill to bring DJ back up when it goes down. Lmk if you need help with the bluepill config.

@dignoe
Copy link

dignoe commented May 31, 2019

Ok, thanks. I've noticed that certain jobs cause DJ to fail, and sometimes DJ will process multiple jobs and just keep on going. All the jobs pass our tests and work fine in production. I'm slowly migrating everything over to ActiveJob and then I'm probably going to switch to Resque anyway, so I'll just live with this until I get everything moved over.

@dignoe
Copy link

dignoe commented Jun 9, 2019

FYI - This issue might be related: #935

I've switched to using foreman in dev mode, so instead of running bin/delayed_job start I'm now just using bin/rails jobs:work in my Procfile. This seems to have solved the issue for me.

@johnnyshields
Copy link

johnnyshields commented Apr 5, 2021

This is expected behavior of the daemons gem. You can see here the first thing it does is to fork the parent and exit I forget exactly why.

If you're ok to run everything in the foreground (e.g. for a container) try my "forking" mode PR: #1138. This is similar to the Rake task except it can now run multiple workers.

@albus522
Copy link
Member

Closing stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants