delayed-job

Rails: Can I run backgrounds jobs in a different server?

不想你离开。 提交于 2019-12-03 16:45:52
Is it possible to host the application in one server and queue jobs in another server? Possible examples: Two different EC2 instances, one with the main server and the second with the queueing service. Host the app in Heroku and use an EC2 instance with the queueing service Is that possible? Thanks Yes, definitely. We have delayed_job set up that way where I work. There are a couple of requirements for it to work: The servers have to have synced clocks. This is usually not a problem as long as the server timezones are all set to the same. The servers all have to access the same database. To do

delayed_job stops running after some time in production

空扰寡人 提交于 2019-12-03 16:37:07
问题 In production, our delayed_job process is dying for some reason. I'm not sure if it's crashing or being killed by the operating system or what. I don't see any errors in the delayed_job.log file. What can I do to troubleshoot this? I was thinking of installing monit to monitor it, but that will only tell me precisely when it dies. It won't really tell me why it died. Is there a way to make it more chatty to the log file, so I can tell why it might be dying? Any other suggestions? 回答1: I've

Preventing delayed_job background jobs from consuming too much CPU on a single server

牧云@^-^@ 提交于 2019-12-03 14:08:40
问题 My Rails application has a number of tasks which are offloaded into background processes, such as image resizing and uploading to S3. I'm using delayed_job to manage these processes. These processes, particularly thumbnailing PDFs (using Ghostscript) and resizing images (using ImageMagick), are CPU intensive and often consume 100% CPU time. Since these jobs are running on the same (RedHat Linux) server as the web application itself, as well as the DB, they can lead to our web application

Autoscaling workers for delayed_job in Rails 3

邮差的信 提交于 2019-12-03 14:04:55
问题 I've been using collectiveidea's fork of delayed_job as a gem in my Rails 3 app, and it's working fine. I'm now looking for a solution to autoscale workers, specifically for Heroku. I've given pedro's fork a try but since it's written for Rails 2, using it throws lots of errors and warnings about deprecated methods and I haven't been able to get it to work successfully. Is there a working solution for Rails 3 delayed_job with autoscaling workers? 回答1: You might want to take a look at workless

Delayed Job: Configure run_at and max_attempts for a specific job

与世无争的帅哥 提交于 2019-12-03 12:32:44
I need to overwrite the Delayed::Worker.max_attempts for one specific job, which I want to retry a lot of times. Also, I don't want the next scheduled time to be determined exponentially (From the docs: 5 seconds + N ** 4, where N is the number of retries). I don't want to overwrite the Delayed::Worker settings, and affect other jobs. My job is already a custom job (I handle errors in a certain way), so that might be helpful. Any pointers on how to do this? I figured it out by looking through delayed_job source code. This is not documented anywhere in their docs. Here's what I did: class

Running delayed_job worker on Heroku?

北慕城南 提交于 2019-12-03 11:33:13
问题 So right now I have an implementation of delayed_job that works perfectly on my local development environment. In order to start the worker on my machine, I just run rake jobs:work and it works perfectly. To get delayed_job to work on heroku, I've been using pretty much the same command: heroku run rake jobs:work . This solution works, without me having to pay anything for worker costs to Heroku, but I have to keep my command prompt window open or else the delayed_job worker stops when I

What's the best way to test delayed_job chains with rSpec?

大憨熊 提交于 2019-12-03 11:15:26
Currently when I have a delayed method in my code like the following: CommentMailer.delay.deliver_comments(@comment, true) I write something like this in my spec: dj = mock("DelayProxy") CommentMailer.should_receive(:delay).and_return(dj) dj.should_receive(:deliver_comments).with(comment, true) Is there a better way to handle this and/or chained methods like that in rSpec in general? We can just have one more line in the before block as following: CommentMailer.stub(:delay).and_return(CommentMailer) Then you then can have the normal mock check as following: CommentMailer.should_receive(

How to make Delayed_Job notify Airbrake when an ActionMailer runs into an error?

跟風遠走 提交于 2019-12-03 11:09:26
The DelayedJob docs mention hooks, including an error hook, but only in the context of custom Job subclasses. This similar question (with no answers) says adding the same hook to the mailer class did not work. What's the trick? Update: In general, I'd like to see how to add hooks to jobs that are triggered using the object.delay.action() syntax, where I don't see an obvious link to a ____Job class. I was just searching for a solution to this problem too, and I found this gist . I don't know where it comes from (found it on Google), but well, it seems to do the job pretty well, is quite simple,

Sending delayed email from devise

风流意气都作罢 提交于 2019-12-03 07:48:10
问题 Is there a simple way of telling Devise to send all email via delayed_job? 回答1: Alternatively, instead of using the Delayed::Mailer gem, you can quite easily implement and use your own ActionMailer "delivery method", one that... intercepts mail delivery from ActionMailer stores the email in a table (optional) creates a Delayed::Job that references the stored email delivers the stored email when the delayed job is executed Do something along the lines of: # in config/application.rb

How do I separate workers into pools of jobs with delayed job + heroku?

久未见 提交于 2019-12-03 07:47:15
My environment is rails 3.1, heroku bamboo stack, delayed_job_active_record, (https://github.com/collectiveidea/delayed_job ) and experimenting with hirefire. (https://github.com/meskyanichi/hirefire) - I can see the delayed_job queue documentation, but how do I apply this on heroku? I have a max priority set of tasks that get spawned off every hour that I need to dedicate 3 workers to, it takes approx 26 minutes to complete. During that time, less important background tasks need to continue, with perhaps 1 worker dedicated to them. So I'll set that block of priority tasks to being in a named