resque

Testing database connection in rspec

偶尔善良 提交于 2019-12-04 06:22:27
问题 I have setup a resque background job that queries the slave database instead of the master. In my resque class I have added code to establish a connection to the slave and then I de-establish the connection at the end of the method. My question is how would I test in rspec that a query is hitting a specific database within a method? Code sample below: class ResqueJob @queue = :resque_job def self.perform(user_id) ActiveRecord::Base.establish_connection( :adapter => "mysql2", :host => "slave

Using Resque, Puma and Scheduler together on Heroku

不问归期 提交于 2019-12-04 04:58:05
问题 After reviewing numerous guides I would like to confirm my setup. Right now my procfile looks like: web: bundle exec puma -C config/puma.rb config.ru resque: TERM_CHILD=1 RESQUE_TERM_TIMEOUT=10 QUEUES=* bundle exec rake resque:work worker: bundle exec rake resque:work COUNT=1 QUEUE=* scheduler: bundle exec rake resque:scheduler ...and in Heroku : ...and my rake resque setup task : require 'resque' require 'resque/tasks' require 'resque/scheduler/tasks' # http://jademind.com/blog/posts/enable

Efficiently reschedule ActiveJob (resque/sidekiq)

老子叫甜甜 提交于 2019-12-03 19:33:04
I'm playing with Rails 4.2 app which uses ActiveJob backed by resque/sidekiq for email scheduling. When a user creates newsletter campaign a new job is created and scheduled on certain date. That's all great but what happens when the user changes the delivery date. In this case every job could check if it should be delivered or not thus invalid jobs would be ignored and only the last one would be executed. This could work but if a user would make 1k edits that would push 1k-1 invalid jobs into queue - not good. I believe that the existing job should be updated or replaced with a new one. As

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

余生颓废 提交于 2019-12-03 17:30:35
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:work" w.start_grace = 30.seconds end god load is use for loading or reloading configurations into an

Have Rails 2.3.x ignore the i18n gem

允我心安 提交于 2019-12-03 17:17:44
问题 I have a Rails 2.3.5 project that uses the localization features of Rails. I also happen to have Rails 3 beta installed (which depends on the i18n gem). Rails 2.3.5 will happily handle localization on it's own (without i18n installed), however if the i18n gem is available, it makes use of it. Recently I upgraded my gems and now have version 0.3.7 and 0.4.0 of i18n installed. Rails, of course, wants to load and use the latest version which is causing errors in my project. I tried setting the

Resque: time-critical jobs that are executed sequentially per user

僤鯓⒐⒋嵵緔 提交于 2019-12-03 15:43:53
My application creates resque jobs that must be processed sequentially per user, and they should be processed as fast as possible (1 second maximum delay). An example: job1 and job2 is created for user1 und job3 for user2. Resque can process job1 and job3 in parallel, but job1 and job2 should be processed sequentially. I have different thoughts for a solution: I could use different queues (e.g. queue_1 ... queue_10) and start a worker for each queue (e.g. rake resque:work QUEUE=queue_1 ). Users are assigned to a queue/ worker at runtime (e.g. on login, every day etc.) I could use dynamic "user

Resque: one worker per queue

不打扰是莪最后的温柔 提交于 2019-12-03 13:17:54
I currently have a Rails 3.0 project, with Ruby 1.9.2 and Resque. My application has multiple worker classes and multiple queues, that are dynamically created (during runtime). Also, there are multiple workers started that are free to work on any queues, because at start time there isn't any existing queues, and they cannot be predicted: $ COUNT=3 QUEUE=* rake resque:workers Queues a created based on the project 's id: @queue = "project_#{project.id}".to_sym For a given queue, their jobs have to processed in order and one at a time. My problem is that, by having multiple workers, multiple jobs

How to stop God from leaving stale Resque worker processes?

岁酱吖の 提交于 2019-12-03 12:44:33
问题 I'm trying to understand how to monitor the resque worker for travis-ci with god in such a way that stopping the resque watch via god won't leave a stale worker process. In the following I'm talking about the worker process, not forked job child processes (i.e. the queue is empty all the time). When I manually start the resque worker like this: $ QUEUE=builds rake resque:work I'll get a single process: $ ps x | grep resque 7041 s001 S+ 0:05.04 resque-1.13.0: Waiting for builds And this

Redis with Resque and Rails: ERR command not allowed when used memory > 'maxmemory'

放肆的年华 提交于 2019-12-03 10:52:29
问题 When using redis, it gives me the error: ERR command not allowed when used memory > 'maxmemory' The info command reveals: redis 127.0.0.1:6379> info redis_version:2.4.10 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:64 multiplexing_api:kqueue gcc_version:4.2.1 process_id:1881 uptime_in_seconds:116 uptime_in_days:0 lru_clock:1222663 used_cpu_sys:0.04 used_cpu_user:0.04 used_cpu_sys_children:0.00 used_cpu_user_children:0.00 connected_clients:1 connected_slaves:0 client_longest_output_list

How to use ActionController::Live along with Resque + Redis (for Chat application)

梦想的初衷 提交于 2019-12-03 09:57:03
问题 I am trying to build a chat feature for my rails application. I am using ActionController::Live , Puma , Resque , Redis for this. So basically in this case, redis subscribe method is running in background using resque . So far what i have done is whenever a user enters a text in below form field i.e. chat box <%= form_tag chat_box_publish_path, method: :get do %> <%= text_field_tag :query, params[:query], class: "form-control", id: "chatSearchBox", placeholder: 'Search' %> <% end %> ..the