delayed-job

Running delayed jobs on Heroku for free

被刻印的时光 ゝ 提交于 2019-12-02 20:35:17
Is it possible to run delayed jobs on Heroku for free? I'm trying to use delayed_job_active_record on Heroku. However, it requires a worker dyno and it would cost money if I turned this dyno on for full time. I thought using Unicorn and making its workers run delayed jobs instead of the Heroku worker, would cost nothing, while successfully running all the jobs. However, Unicorn workers do not seem to start "working" automatically. I have the following in my Procfile . web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb worker: bundle exec rake jobs:work and the following in my unicorn.rb

Rails/Rspec: Testing delayed_job mails

和自甴很熟 提交于 2019-12-02 20:18:22
Just wondering how to test that actionmailer requests are actually sent to the delayed_job que in rspec. I would have assumed it was quite simple, but my delayed_job queue doesn't seem to be incrementing. Code below: Controller: def create @contact = Contact.new(params[:contact]) if @contact.save contactmailer = ContactMailer contactmailer.delay.contact_message(@contact) redirect_to(contacts_url) else render :action => "new" end Spec: it "queues mail when a contact is created" do expectedcount = Delayed::Job.count + 1 Contact.stub(:new).with(mock_contact()) { mock_contact(:save => true) } post

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

佐手、 提交于 2019-12-02 14:20:40
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 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. David Tuite You can also do it like this: Delayed::Worker.new.run( Delayed::Job.find(x) ) On Heroku I had a

Hook before all delyed job success callback to save successfully completed jobs

点点圈 提交于 2019-12-02 12:27:40
问题 Objective: To save successfully completed jobs Methods used Have looked at this answer which tells how to save completed jobs and this answer which suggests to create a plugin which will be executed after one of lifecycle events. Problem There are following lifecycle events, and applicable arguments as present in code: :enqueue => [:job], :execute => [:worker], :loop => [:worker], :perform => [:worker, :job], :error => [:worker, :job], :failure => [:worker, :job], :invoke_job => [:job] I had

How do I handle long requests for a Rails App so other users are not delayed too much?

久未见 提交于 2019-12-02 10:14:56
I have a Rails app on a free tier on Heroku and it recently started getting some users. One of the events in my app involves querying another API and can take up to 10 seconds to finish. How do I make sure other users who visit a simple page at the same time (as another user's API event) don't need to wait 10 seconds for their page to load? Do I need to pay for more Dynos? Is this something that can be solved with the delayed_job gem? Would another host (like AppFog or OpenShift) be able to handle simultaneous requests faster? Update: This question suggest manually handling threads instead of

Knowing when resque worker had completed job

混江龙づ霸主 提交于 2019-12-02 09:09:23
I am performing some job with Resque-worker (5 workers). Now, when this job is completed/done I want to trigger another worker which processes the data previous worker stored in db. What would be the most appropriate method of doing this? I'm not sure if this is of any help, but have you had a look at the resque-status gem? That way you can track a given jobs' status, to see when it is completed. But I'm affraid there are no auto-trigger functionality, to start new workers. 来源: https://stackoverflow.com/questions/8383259/knowing-when-resque-worker-had-completed-job

delayed_job: NoMethodError

回眸只為那壹抹淺笑 提交于 2019-12-02 07:49:34
问题 Here is my tiny Rails3 controller: class HomeController < ApplicationController def index HomeController.delay.do_stuff end def self.do_stuff puts "Hello" end end Upon accessing index , the job gets correctly inserted in database: --- !ruby/struct:Delayed::PerformableMethod object: !ruby/object:Class HomeController method_name: :do_stuff PROBLEM: When executing bundle exec rake jobs:work , I get: Class#do_stuff failed with NoMethodError: undefined method `do_stuff' for #<Class

delayed_job queue not being processed on Heroku

◇◆丶佛笑我妖孽 提交于 2019-12-02 07:17:34
问题 I'm running a Rails 3 app with delayed_job. The issue I've come across is that though the app is correctly adding jobs to the queue, they are never being processed. My Class class User < ActiveRecord::Base after_create :send_welcome_email private def send_welcome_email UserMailer.delay.welcome_email(self) end end Inspecting things through the Rails console I can see that there are jobs in the queue. I can also see that there have been 0 attempts to perform the jobs. Spinning up a Heroku

Hook before all delyed job success callback to save successfully completed jobs

泪湿孤枕 提交于 2019-12-02 06:23:06
Objective: To save successfully completed jobs Methods used Have looked at this answer which tells how to save completed jobs and this answer which suggests to create a plugin which will be executed after one of lifecycle events. Problem There are following lifecycle events, and applicable arguments as present in code : :enqueue => [:job], :execute => [:worker], :loop => [:worker], :perform => [:worker, :job], :error => [:worker, :job], :failure => [:worker, :job], :invoke_job => [:job] I had expected there will be some event corresponding to success, I am not getting which one will be

Heroku & Delayed Job - Autoscale Branch - RestClient::ResourceNotFound

风格不统一 提交于 2019-12-02 05:09:18
SomeController#update (RestClient::ResourceNotFound) "Resource Not Found" I'm receiving this error (where previously I was not) while trying to enqueue delayed jobs using the autoscale branch of DelayedJob. This does not occur with a none autoscale branch but I'm at a loss to pinpoint what the problem is. If anyone is experiencing the same or can point me toward a likely cause I'd be grateful for advice. Just a guess... Is it possible the ResourceNotFound is occurring because the heroku gem cannot find your app when making the API requests to auto-scale? Try using the heroku gem outside your