delayed-job

Dealing with very long running rake task

偶尔善良 提交于 2019-12-03 07:18:51
问题 I am interested in running a very long running rake task, one that would take hours to complete and I am interested in learning about best practices for dealing with this problem. Possible solutions I have found: Set up a cron job delayed_job resque cron seems like a simple solution to set up, but is it ideal for a very long task? What do you use and what are the advantages/disadvantages of your solution? 回答1: Personally I love Resque, you can use the resque-scheduler gem for dealing with

What's the most elegant way to implement a digest email without reinventing a queueing system?

孤者浪人 提交于 2019-12-03 03:34:57
I have my transactional email system setup & by default people get emails as events happen: class Comment after_create :email_original_poster def email_original_poster UserMailer.delay.notify_author_of_comment self end end However instead of getting the email as-it-happens, a chunk of my users would prefer a daily or weekly digest. What's the cleanest most elegant way to implement this? I've already got delayed_job running but this doesn't really feel like a delayed_job job since I'm queueing data that needs to be acted on rather than actions that need to be executed. ...without reinventing a

Delayed Job not logging in Production

人盡茶涼 提交于 2019-12-03 03:24:37
I want my delayed job "code" to log in a different log file for business requirements. So I log a custom status in a log called as dj.log. Inside the "serialized" job, I am putting the log statements to log in my file. Here is how the setup is Delayed::Worker.destroy_failed_jobs = false Delayed::Worker.sleep_delay = 60 Delayed::Worker.max_attempts = 10 Delayed::Worker.delay_jobs = !( Rails.env.test? || Rails.env.development? ) #dont use delayed_job in development or test mode #Delayed_job custom logger DJ_LOGFILE = File.join(Rails.root, 'log', 'dj.log') and here is the job that the workers

Invoke delayed_job capistrano tasks only on specific servers

旧城冷巷雨未停 提交于 2019-12-03 03:10:45
I have a dedicated server for delayed_job tasks. I want to start, stop, and restart delayed_job workers on only this server. I am using the capistrano recipes provided by delayed_job. When I only had 1 server, this was my config: before "deploy:restart", "delayed_job:stop" after "deploy:restart", "delayed_job:start" after "deploy:stop", "delayed_job:stop" after "deploy:start", "delayed_job:start" Now I want to have those hooks only apply to a separate delayed_job server ( role :delayed_job <ip address> ). Is this possible to do elegantly? Do I have to wrap each delayed_job tasks in a meta task

Running delayed_job worker on Heroku?

☆樱花仙子☆ 提交于 2019-12-03 01:54:14
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 close it. Is there a command to permanently keep this delayed_job worker working even when I close the

How do you tell a specific Delayed::Job to run in console?

岁酱吖の 提交于 2019-12-03 00:59:13
问题 For some reason, Delayed::Job's has decided to queue up but not excecute anything even though I've restarted it several times, even kill -9'd it and restarted it. It won't run any jobs. Can I , in /console, specify a specific job and tell it to work? Ex:.. Delayed::Job.find(x).run 回答1: answering how to run specific job from console: Delayed::Job.find(x).invoke_job but you must remember that it won't run any other things like destroying job that was done or so on. just running the job/task.

Is Rails's “delayed_job” for cron task really?

这一生的挚爱 提交于 2019-12-02 23:59:10
delayed_job is at http://github.com/collectiveidea/delayed_job Can delayed_job have the ability to do cron task? Such as running a script every night at 1am. Or run a script every 1 hour. If not, what are the suitable gems that can do that? And can it be monitored remotely using a browser, and have logging of success and error? I worked on a project that tried to use DelayedJob to schedule future items. It sucked. Instead I recommend you use the whenever gem: http://github.com/javan/whenever Whenever is a Ruby gem that provides a clear syntax for defining cron jobs. It outputs valid cron

Paperclip, Delayed Job, S3, Heroku - design for delayed processing of sensitive uploaded files: db or s3?

穿精又带淫゛_ 提交于 2019-12-02 21:22:14
I need feedback on the design for uploading and delayed processing of a file using heroku, paperclip, delayed job and, if necessary, s3. Parts of it have been discussed in other places but I couldn't find a complete discussion anywhere. Task description: Upload file (using paperclip to s3/db on heroku). File needs to be private as it contains sensitive data. Queue file for processing (delayed job) Job gets run in queue File is retrieved (from s3/db), and processing is completed File is deleted (from s3/db) Since I am using delayed job, I have to decide between storing the file in the database

Sending delayed email from devise

≯℡__Kan透↙ 提交于 2019-12-02 21:14:12
Is there a simple way of telling Devise to send all email via delayed_job? 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 ActionMailer::Base.add_delivery_method :queued, Mail::QueuedDelivery # in config/environment.rb (or one of the config

Dealing with very long running rake task

孤人 提交于 2019-12-02 20:52:37
I am interested in running a very long running rake task, one that would take hours to complete and I am interested in learning about best practices for dealing with this problem. Possible solutions I have found: Set up a cron job delayed_job resque cron seems like a simple solution to set up, but is it ideal for a very long task? What do you use and what are the advantages/disadvantages of your solution? Personally I love Resque, you can use the resque-scheduler gem for dealing with long running or periodic tasks. If you don't have to run your task very often, you can demonize the the rake