delayed-job

How to Make the Controller wait for a Delayed Job while the rest of the App continues on?

我只是一个虾纸丫 提交于 2019-12-11 11:56:16
问题 (This question is a follow-up to How do I handle long requests for a Rails App so other users are not delayed too much? ) A user submits an answer to my Rails app and it gets checked in the back-end for up to 10 seconds. This would cause delays for all other users, so I'm trying out the delayed_job gem to move the checking to a Worker process. The Worker code returns the results back to the controller. However, the controller doesn't realize it's supposed to wait patiently for the results, so

Heroku: delayed job sending email multiple times

三世轮回 提交于 2019-12-11 08:45:23
问题 We have one application(Rails 3) deployed in Heroku. For sending email digest to nearly about 500 users, we are using delayed_job. Notifier.delay.send_email_digest(digest_content, @user) My application has 3 web dynos and 2 worker dynos. Though the task is sending only one Email digest per user in local, In heroku (production) it's sending two email digests for some users (strange). Is it due to two worker dynos (but why?? or mere coincidence). Can anybody help me solve the problem? Thanks.

delayed_job in rails docker is not working properly

会有一股神秘感。 提交于 2019-12-11 07:35:22
问题 I have shifted my rails application to docker. Everything is working fine except the rails delayed_job. I have use delayed_job to send email. I have started my job through command docker-compose run web rake jobs:work it has started succesfully as shown in the image. Now when I am trying to send email in console it is showing that the email is initiated as shown in the above image. Do I have to include any line in my docker-compose.yml or Dockerfile. My Dockerfile is : FROM ruby:2.3.6 RUN

Setting sleep time in delayed job

核能气质少年 提交于 2019-12-11 07:25:29
问题 Ok,a simple question. I want to change sleep time for my delayed job worker. How do I do it in the current version? I've found out two suggestions for this: Delayed::Worker.const_set("SLEEP", sleep_time_in_seconds) and Delayed::Worker.sleep_delay = sleep_time_in_seconds . What's the difference between those two? Thanks 回答1: It depends on what version of delayed_job you are using. If you are using the tobi version (https://github.com/tobi/delayed_job) you should set the constant: Delayed:

Make delayed job run at specific date time

眉间皱痕 提交于 2019-12-11 04:41:49
问题 I want to send some emails through delayed_job However, I want to send them before and after an event. My concern is if this will actually work: def one_week_before_run AtendeeMailer.delay(run_at: '8th October 2016'.to_datetime).mudrun_about_to_start(self) end def thank_you_note AtendeeMailer.delay(run_at: '18th October 2016'.to_datetime.end_of_day).thank_you(self) end or should I choose another approach? 回答1: Delayed job picks a job to execute only if the run_at <= current time. Refer DJ's

How to set max_run_time for a specific job?

六月ゝ 毕业季﹏ 提交于 2019-12-11 03:36:39
问题 I want to set Delayed::Worker.max_run_time = 1.hour for a specific job that I know will take a while. However, this is set as a global configuration in initializers/delayed_job_config.rb . As a result, this change will make ALL of my jobs have a max run time of 1 hour. Is there a way to just change it for one specific job without creating a custom job? 回答1: Looking at the Worker class on GitHub: def run(job) job_say job, 'RUNNING' runtime = Benchmark.realtime do Timeout.timeout(self.class.max

Sending dynamic email reminders in Ruby on Rails?

帅比萌擦擦* 提交于 2019-12-11 03:22:33
问题 I'm relatively new to actionmailer however I have set up forgot password emails and have them running as delayed jobs already. I would like to set up dynamic email reminders where users can select options like "Remind me _ __ minutes/hours/days" before an event start and have it send an email reminder. I don't want to leave it completely open-ended and will have a dropdown with the following options: Remind me at the time of event Remind me 5/15/30 minutes before the event Remind me 1 hour

Uploading to S3 on Heroku with Paperclip (delayed_job question)

人盡茶涼 提交于 2019-12-11 03:09:17
问题 I'm trying to upload to a portfolio app I've built, specifically trying to find where to hook delayed_job into the process. It all works otherwise. Right now it returns undefined method 'call' for #<Class:0xae68750> on app/controllers/portfolio_items_controller.rb:18:in 'create' so here's my model and that portion of the controller... anyone see anything that could be going wrong? The hook I'm using now I got from this blog: http://madeofcode.com/posts/42-paperclip-s3-delayed-job-in-rails

DelayedJob: How to solve the problem “Job failed to load”?

依然范特西╮ 提交于 2019-12-11 00:32:24
问题 I am using Ruby on Rails 3.1.0 and DelayedJob. As many people on the web I get the " Job failed to load: uninitialized constant Syck::Syck " error, but I think I discovered at least what generates the error (in my case). I have an ActiveModel like the following: class Contact include ActiveModel::Conversion include ActiveModel::Validations include ActiveModel::Dirty extend ActiveModel::Naming extend ActiveModel::Translation attr_accessor :full_name, :email, :subject, :message def initialize

Why does my delayed_job fail without RVM?

随声附和 提交于 2019-12-10 18:37:53
问题 I have a delayed_job installed, and I start the daemon to run the jobs with this Ruby script: require 'rubygems' require 'daemon_spawn' $: << '.' RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) class DelayedJobWorker < DaemonSpawn::Base def start(args) ENV['RAILS_ENV'] ||= args.first || 'development' Dir.chdir RAILS_ROOT require File.join('config', 'environment') Delayed::Worker.new.start end def stop system("kill `cat #{RAILS_ROOT}/tmp/pids/delayed_job.pid`") end end