delayed-job

How to reference active delayed_job within the actual job

核能气质少年 提交于 2019-12-06 03:57:55
问题 I am working on a solution to display the percentage completion of a delayed job (using the delayed_job gem). At the present, I have a database migration that looks like the following for my delayed_jobs table: class CreateDelayedJobs < ActiveRecord::Migration def self.up create_table :delayed_jobs, :force => true do |table| table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue table.integer :attempts, :default => 0 # Provides for retries, but still fail

monitoring multiple delayed job workers with monit

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 02:06:19
问题 I have read a lot about monitoring delayed_job with monit. The implementation is pretty easy and straight forward. But When one worker is not enough how do I setup monit to ensure that, let's say, 10 workers are constantly running? 回答1: You can just replicate the same config you have for the first worker N times. Suppose you have 5 workers, you'll monitor all of them with the following: check process delayed_job.0 with pidfile /path/to/shared/pids/delayed_job.0.pid start program = "/bin/su -c

Delayed Job giving a undefined method error

北慕城南 提交于 2019-12-06 02:03:38
问题 Delayed job (2.1.4) is working perfectly on my development machine, sending emails with gay abandon - however it is failing miserably when running on my server using Apache/Passenger(3.0.7). Rails 3.0.7 and ruby 1.9.2 on both btw. I have seen that there is a problem when using thin where the job is created like this: --- !ruby/struct:Delayed::PerformableMailer object: !ruby/object:Class UserMailer when it should read: --- !ruby/struct:Delayed::PerformableMailer object: !ruby/class UserMailer

How to start delayed job workers in production mode

邮差的信 提交于 2019-12-06 01:59:43
问题 I was following railscast for delayed job. Things are working perfectly on my machine. How can start delayed_job workers in production mode? I am using delayed_job gem,(2.1.4) 回答1: RAILS_ENV=production script/delayed_job start For Rails 4 RAILS_ENV=production bin/delayed_job start Solved my problem. It may give you an error that tmp directory doesn't exists. Just create one and run previous command again.. 回答2: You can try to run the following command: RAILS_ENV=production cd ~/path_to_your

Delayed job with custom attributes

一曲冷凌霜 提交于 2019-12-06 01:22:25
I'm using delayed job 3.0.2 with ActiveRecord and Rails 3.2.3. I have a User model which uses the has_secure_password mixin, so the password is only stored encrypted. Now I want to use delayed job to send the welcome email, which should contain a copy of the unencrypted password. When creating the record, the plain-text password is in User#password. But delayed job seems to serialize/ deserialize the id of the record only and create a new instance of the model by doing User.find(X). This way my plain-text password is lost and the user gets an empty password in his email. How can I tell delayed

run multi delayed_job instances per RAILS_ENV

痴心易碎 提交于 2019-12-05 23:18:55
问题 I'm working on a Rails app with multi RAILS_Env env_name1: adapter: mysql username: root password: host: localhost database: db_name_1 env_name2: adapter: mysql username: root password: host: localhost database: db_name_2 ... .. . And i'm using delayed_job (2.0.5) plugin to manage asynchrone and background work. I would like start multi delayed_job per RAILS_ENV: RAILS_ENV=env_name1 script/delayed_job start RAILS_ENV=env_name2 script/delayed_job start .. I noticed that I can run only one

Rails + foreman + worker hangs server

℡╲_俬逩灬. 提交于 2019-12-05 22:52:05
问题 On my local machine I'm trying to start my rails app and delayed job worker using Foreman. My Procfile looks like this: web: bundle exec rails server -p $PORT worker: bundle exec rake jobs:work When I start foreman only the first two web requests get executed. With the third request the server hangs. The first request is outputted in the console, the second isn't. If I leave out the worker in my Procfile the server is running just fine and is outputting everything to the console. Also when I

How can I force delayed_job to use a specific db connection?

大兔子大兔子 提交于 2019-12-05 22:43:08
问题 I have a Rails 3 applications that uses different databases depending on the subdomain. I do this by using "establish_connection" in the ApplicationController. Now I'm trying to use delayed_job gem to do some background processing, however it uses the database connection that it's active in that moment. It's connecting to the subdomain database. I'd like to force it to use the "common" database. I've done this for some models calling "establish_connection" in the model like this: class

Running code after Rails is done loading?

a 夏天 提交于 2019-12-05 21:28:13
问题 I have a periodic task that needs to execute once a minute (using delayed_job). I would like for Rails to automatically queue it up as soon as it's finished loading, if one such task isn't already present in the system. What is a good place for me to run some code right at the end of the entire Rails boot flow? Someone suggested config/environments/development.rb (or other environment), but delayed_job give me ActiveRecord issues when I queue up jobs from there. I consulted http://guides

Delayed job and Mandrill: uninitialized constant Mandrill::API

烂漫一生 提交于 2019-12-05 21:20:37
I have mailer service where users can upload an .xls file with emails and some other user related data to send an email campaign. I was having some timeout issues since it takes some seconds to process (as I do some validation and configuration for each email to be sent, eg: save records to database, check if an email was sent in the last 30 days, create personalised html code for each email (to create links that contain the email address as a parameter, etc). After some research, moving this to a delayed job seemed reasonable, as suggested in this rails cast . The only problem is that I am