resque

Does Rake task need to run in the background using Resque?

依然范特西╮ 提交于 2019-12-25 16:41:49
问题 I have this code in my rake task. It seems overkill, since the rake task is already being run as a cron job. I think I can safely take it out of Resque and run it directly, but not sure if I missed something. desc "update daily sales" task :daily_sales => :environment do Resque.enqueue(DailySaleService.perform) end 回答1: Yes, it's overkill. There is no reason to use background processing for a rake task; you use background processing to remove heavy lifting from the HTTP request/response cycle

Rails custom environment Resque.enqueue does not create jobs

筅森魡賤 提交于 2019-12-25 03:25:31
问题 I'm using Resque for a couple of asynchronous jobs. I've set up a custom environment integration which is a clone of my production environment. However, my Resque jobs do not get added to Redis in my integration environment. For example, if I run the following: $ RAILS_ENV=production rails console > Resque.enqueue(MyLovelyJob, 1) I will see the job appear in resque-web. But, if I run the following: $ RAILS_ENV=integration rails console > Resque.enqueue(MyLovelyJob, 1) The job does not appear

resque-web with rails api only mode

房东的猫 提交于 2019-12-24 08:27:04
问题 1. What is the best way I can use resque-web with rails API-only mode? My application uses resque with four separate job servers fur running the queues. I have mounted resque-web and I run it on local machine. it works fine only to show me the information about workers and queues. However, if I try to 'retry failed' jobs or 'delete a queue', it gives me routing error. 2. Is there any readymade way to expose all the routes used by resque-web as a json API? So that I can design my own JS front

Resque is returning Mysql2::Error: closed MySQL connection: SHOW FIELDS FROM `users`

只愿长相守 提交于 2019-12-24 03:34:18
问题 Resque is returning Mysql2::Error: closed MySQL connection: SHOW FIELDS FROM users Worker 8608f362-819b-4c15-b42b-69c4df00d27b:1 on low at about 16 hours ago Class AddLiveView Arguments 4383 {"remote_ip"=>"184.72.47.71", "expires"=>true} Exception ActiveRecord::StatementInvalid Error Mysql2::Error: closed MySQL connection: SHOW FIELDS FROM `users` /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `query' /app/vendor/bundle

How do I get the number of jobs in a rq queue?

被刻印的时光 ゝ 提交于 2019-12-23 23:41:17
问题 I've using rq and RedisToGo. How do I get the number of jobs in the queue? I can't find it in the documentation? (In Python) When I try: print "Before: ", len(q.jobs) result = q.enqueue(worker.A) result = q.enqueue(worker.B) print "After: ", len(q.jobs) It just gives 0 both times. 回答1: For RQ, you should be able to just get the len of the jobs in a queue: from rq import Queue queue = Queue() len(queue.jobs) 来源: https://stackoverflow.com/questions/14449296/how-do-i-get-the-number-of-jobs-in-a

Pass file to Active Job / background job

爷,独闯天下 提交于 2019-12-23 17:28:01
问题 I'm receiving a file in a request params through a standard file input def create file = params[:file] upload = Upload.create(file: file, filename: "img.png") end However, for large uploads, I'd like to do this in a background job. Popular background jobs options like Sidekiq or Resque depend on Redis to store the parameters, so I can't just pass a file object through redis. I could use a Tempfile , but on some platforms such as Heroku, local storage is not reliable. What options do I have to

ActiveJob with Resque: enqueuing jobs with uninteded arguments

六眼飞鱼酱① 提交于 2019-12-23 16:52:46
问题 Trying to implement some kind of cancel job functionality. In order to destroy a job with Resque, one needs the specific arguments passed to it. It appears I'm passing in unintended information by mistake though. I'm expecting just the arguments value to be within the outside brackets. I'm creating the job like so: PhysicalServerProvisionJob.perform_later('123') I'd like to be able to: Resque::Job.destroy(:default, PhysicalServerProvisionJob, '123') However this isn't possible due to the

Rails - ActionDispatch::Http::UploadedFile in background job

余生长醉 提交于 2019-12-23 07:47:57
问题 I'm using a similar idea as in the importing csv and excel Railscast but as the standard code in that episode takes some time to process (uses ActiveRecord to create a new record for each row in the file) I'm getting timeouts on Heroku and would like to move the import process to a background job. I have been unsuccessful at sending the file variable (which is of type ActionDispatch::Http::UploadedFile) to the job so instead I sent individual variables of the file.original_filename and file

How do I create a resque worker automatically at bootup?

谁说我不能喝 提交于 2019-12-22 08:09:00
问题 Ok, I'm making my first ruby app. Who know moving everything over to 'production' is so fugging complicated. So far I've struggled my way through configuring passenger, getting it to run on startup, then getting redis to run on startup. My last task is on startup to add 1 worker. Right now, I have to ssh in and run my rake command rake workers:start . Obviously this is no good when I want to close ssh.. so I just dont really know how or what the next step is. I tried copying resque default

Rails Resque undefined method error in external module

╄→гoц情女王★ 提交于 2019-12-22 04:17:38
问题 I'm having trouble calling methods from an included module inside a resque worker. In the example below, I keep getting undefined method errrors when I attempt to call the say method inside the worker (which is in the TestLib module). I've reduced the code down to bare basics to illustrate the issue: Controller (/app/controllers/test_controller.rb) class TestController < ApplicationController def testque Resque.enqueue( TestWorker, "HI" ) end end Library (/lib/test_lib.rb) module TestLib def