resque

Run rails code after an update to the database has commited, without after_commit

对着背影说爱祢 提交于 2019-12-22 03:48:40
问题 I'm trying to battle some race cases with my background task manager. Essentially, I have a Thing object (already exists) and assign it some properties, and then save it. After it is saved with the new properties, I queue it in Resque, passing in the ID. thing = Thing.find(1) puts thing.foo # outputs "old value" thing.foo = "new value" thing.save ThingProcessor.queue_job(thing.id) The background job will load the object from the database using Thing.find(thing_id) . The problem is that we've

Sending Devise emails through Resque

余生长醉 提交于 2019-12-22 03:08:08
问题 I'm trying to send Devise emails through Resque. Regular emails are getting sent through Resque just fine. And Devise emails are sent just fine, but not Devise emails through Resque. I get "Could not find a valid mapping" which implies that my helper overrides aren't getting picked up. I'm following this http://shaker.4-dogs.biz/2011/08/06/using-resque-to-send-mail-for-devise/ The odd thing is that to debug it I'm using a local copy of Devise and adding breakpoints in 'initialize_from_record'

How to specify a default queue to use for all jobs with Resque in Rails?

独自空忆成欢 提交于 2019-12-21 16:57:44
问题 I want all the enqueue calls to default to a certain queue unless specified otherwise so it's DRY and easier to maintain. In order to specify a queue, the documentation said to define a variable @queue = X within the class. So, I tried doing the following and it didn't work, any ideas? class ResqueJob class << self; attr_accessor :queue end @queue = :app end class ChildJob < ResqueJob def self.perform end end Resque.enqueue(ChildJob) Resque::NoQueueError: Jobs must be placed onto a queue.

Resque multiple workers in development mode

﹥>﹥吖頭↗ 提交于 2019-12-20 09:19:07
问题 Hi is it possible to run multiple Resque workers simultaneously in development? I found this bit of code, but not sure if it will work and how.. http://pastebin.com/9GKk8GwR So far I am using the standard bundle exec env rake resque:work QUEUE='*' redis-server /usr/local/etc/redis.conf 回答1: You need to add a COUNT environment variable and then change resque:work to resque:workers . For example, to start 3 workers: bundle exec env rake resque:workers QUEUE='*' COUNT='3' 回答2: The only way I

Logging issues with Resque

泪湿孤枕 提交于 2019-12-18 16:55:47
问题 I have added Resque to my Rails 3 project. I have created a job which reads/writes some stuff from/to the DB. The problem is I do not see the SQL query logs such as "Post Load (0.5ms) SELECT "posts".* FROM "posts"" in the terminal anymore. I am also not seeing any Rails.logger messages I have set up. When I make yet another request (simple refresh) the logger messages and SQL query logs suddenly show up. Any ideas what could be going on? Thanks 回答1: Rails won't write out to the log file

Rails: Exception in after_create stopping save

倖福魔咒の 提交于 2019-12-18 02:01:29
问题 Simple question. I have a ActiveRecord model that I want to perform post processing on AFTER the record is saved. So in the model I have a queue_for_processing method that sticks a job onto my Resque queue. To make this execute after my record is successfully persisted I have written the following in my model: after_create :queue_for_processing Pretty simple. I had thought that everything was working as expected EXCEPT that last night my redis server went down and things went awry. My

Rails: Exception in after_create stopping save

旧巷老猫 提交于 2019-12-18 02:01:07
问题 Simple question. I have a ActiveRecord model that I want to perform post processing on AFTER the record is saved. So in the model I have a queue_for_processing method that sticks a job onto my Resque queue. To make this execute after my record is successfully persisted I have written the following in my model: after_create :queue_for_processing Pretty simple. I had thought that everything was working as expected EXCEPT that last night my redis server went down and things went awry. My

Best Ruby on Rails Architecture for Image Heavy App

醉酒当歌 提交于 2019-12-17 17:29:30
问题 I'm building an application that allows for large amounts of photo uploads at once, and wanted to know what the best setup would be to tackle this. This is what I am using so far: Jquery File Upload: allows users to drag and drop images CarrierWave: Processes images and resizes them with ImageMagick Amazon S3: CarrierWave uploads images to Amazon S3 through Fog Heroku: for hosting I'd like to allow users to be able to drag and drop a large amount of images onto a page, and then navigate to

Importing chunks of CSV rows with Sidekiq, Resque, etc

故事扮演 提交于 2019-12-13 05:14:04
问题 I'm writing an importer that imports data from a CSV file into a DB table. To avoid loading the whole file into memory, I'm using Smarter CSV to parse the file into chunks of 100 to load each chunk one at a time. I'll be passing each chunk of 100 to a background job processor such as Resque or Sidekiq to import those rows in bulk. Passing 100 rows as a job argument results in a string that's about ~5000 characters long. Does this cause any problems in general or particularly with the back-end

Generating file with PDFKit on Heroku - No such file or directory

余生长醉 提交于 2019-12-13 01:24:51
问题 I'm using PDFKit to create pdfs of from a given url within a Resque job on Heroku Cedar. My code looks like: kit = PDFKit.new(url) pdf = kit.to_file("/tmp/#{SecureRandom.hex}.pdf") I then upload the file using fog to S3 for permanent storage. This job usually works, but also fails maybe a third of the time with: No such file or directory - /tmp/a05c165fc80878b75fd15c447695de71.pdf Manually running through the code in console will produce the same error. According to the Heroku docs, I should