resque

Rails Resque undefined method error in external module

六月ゝ 毕业季﹏ 提交于 2019-12-05 04:12:50
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 say( word ) puts word end end Worker (/workers/test_worker.rb) require 'test_lib' class TestWorker

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

拈花ヽ惹草 提交于 2019-12-05 01:39:44
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 found Resque is so fast at picking up the job and loading the Thing object from the ID, that it loads a

Sending Devise emails through Resque

六月ゝ 毕业季﹏ 提交于 2019-12-05 01:35:51
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' in Devise, which gets hit when I just use Devise alone. But when I send the Devise emails through

God not running: The server is not available (or you do not have permissions to access it)

北城余情 提交于 2019-12-05 01:04:26
问题 I'm attempting to get god to start up my resque queue. However when I run god load config/resque.god it returns The server is not available (or you do not have permissions to access it) This is my resque.god file: rails_env = ENV['RAILS_ENV'] || "production" rails_root = ENV['RAILS_ROOT'] || "/Users/andrewlynch/sites/wellness/wellbot" God.watch do |w| w.name = "resque-worker" w.group = "resque" w.interval = 60.seconds w.dir = "#{rails_root}" w.start = "RAILS_ENV=development QUEUE=* rake

Resque, Resque Server, on RedisToGo with Heroku

半世苍凉 提交于 2019-12-04 21:48:48
问题 I've been trying to get Resque (with Resque server) & RedisToGo working on heroku (cedar) for awhile now, but I keep running into this error: Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)): Its working locally, and I can access redis just fine in Heroku's console for my app. My Procfile has: web: bundle exec thin start -p $PORT -e $RACK_ENV web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb resque: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=10 bundle

resque-status and resque-scheduler for delayed jobs

淺唱寂寞╮ 提交于 2019-12-04 17:54:44
I used resque-scheduler for delay jobs in previous code: Resque.enqueue_in(options[:delay].seconds, self, context) Now I want to include resque-status to do the job but have no idea how they can work together. The latest resque-status source code supports scheduler, as in the source code: https://github.com/quirkey/resque-status/blob/master/lib/resque/plugins/status.rb # Wrapper API to forward a Resque::Job creation API call into a Resque::Plugins::Status call. # This is needed to be used with resque scheduler # http://github.com/bvandenbos/resque-scheduler def scheduled(queue, klass, *args)

Multiple resque workers mode creating extra processes

吃可爱长大的小学妹 提交于 2019-12-04 12:05:15
问题 I need to start 4 resque workers so i used following command bundle exec rake environment resque:workers RAILS_ENV=production COUNT=4 QUEUE=* VERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid >> log/resque_worker_QUEUE.log But going to web interface, it was actually starting 8 workers. There were two parent processes with 4 child processes each. Following is tree view of the processess: ruby /code_base/bundle/ruby/1.9.1/bin/rake environment resque:workers RAILS_ENV=production COUNT=4 QUEUE=*

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

时间秒杀一切 提交于 2019-12-04 07:45:12
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. from /Library/Ruby/Gems/1.8/gems/resque-1.10.0/lib/resque/job.rb:44:in `create' from /Library/Ruby/Gems/1

Resque on Heroku cedar stack Worker count still exists after the worker terminate

╄→гoц情女王★ 提交于 2019-12-04 07:28:59
I have successfully run resque on heroku cedar stack and mount the interface on rails. when I start the worker, Everything works fine. The worker process the job. But When i kill the worker, Resque still think that the worker is available. When I start another worker, it then think there are 2 worker but in fact there is only one running. I also notice form here http://devcenter.heroku.com/articles/ps that heroku send SIGTERM when killing a worker and if that does not terminate then it send SIGKILL. here is my worker logs 2011-08-11T02:32:45+00:00 heroku[worker.1]: Starting process with

Knowing when resque worker had completed job

烂漫一生 提交于 2019-12-04 06:25:13
问题 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? 回答1: 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:/