sidekiq

Sidekiq - could not obtain a database connection within 5.000 seconds

廉价感情. 提交于 2019-11-29 16:36:25
问题 I get the following warning with Rails 4 and Sidekiq on os x on development 10:13:39 worker.1 | 2014-09-22T07:13:39.857Z 86981 TID-oug0oog10 WARN: could not obtain a database connection within 5.000 seconds (waited 5.002 seconds) 10:13:39 worker.1 | 2014-09-22T07:13:39.857Z 86981 TID-oug0oog10 WARN: /Users/me/.rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block in wait_poll' I read other answers that say to reduce the

Mailer unable to access reset_token in User model

懵懂的女人 提交于 2019-11-29 16:16:53
faced with an issue where @user.reset_token returns nil. app/views/user_mailer/password_reset.html.erb <%= link_to "Reset password", edit_password_reset_url(@user.reset_token, email: @user.email) %> Reset_token is declared in User model, whereby this problem happens when I try to use a sidekiq worker. Refer to code below. app/models/user.rb class User < ActiveRecord::Base attr_accessor :reset_token def User.new_token SecureRandom.urlsafe_base64 end def send_password_reset_email PasswordResetWorker.perform_async(self.id) end private def create_reset_digest self.reset_token = User.new_token

failed with error 10068: “invalid operator: $oid”

笑着哭i 提交于 2019-11-29 13:48:35
just updated to the latest version of mongoid (3.1.0) and sidekiq (2.7.2) now i'm getting the error : failed with error 10068: "invalid operator: $oid" from looking into the code i see a select like that: @selector={"_id"=>{"$oid"=>"[some id]"}} what can get wrong here? adding this to my gemfile fixed the issue: gem 'multi_json', '1.5.1' i guess something is wrong with the latest version (1.6.0) EDIT: the gem has been updated to new version (1.6.1) that fixed this issue. more here: https://github.com/intridea/multi_json/issues/89 This is actually happening because BSON::ObjectId is not part of

Run Delayed Jobs and Sidekiq at the same time

a 夏天 提交于 2019-11-29 11:52:09
问题 I currently use delayed job to process jobs asynchronously. Instead of creating workers, I use the .delay method a lot. I want to move to Sidekiq, but I have too many types of jobs, and can't make sure all of them are thread safe. So I want to run Delayed Job and Sidekiq in parallel, and migrating one type of job at a time. Since both Delayed Job and Sidekiq offers the .delay method, how can I make the distinction between the two? Are there any other potential issues? 回答1: For Sidekiq 2.17.1

Redis pub/sub on rails

孤街醉人 提交于 2019-11-29 02:48:22
问题 Following the Redis Pub/Sub this works fine and i can publish messages in any class using $redis.publish 'channel', { object: @object.id } using redis-cli > MONITOR , I can verify that this request was published correctly [0 127.0.0.1:64192] "publish" "channel" "{:object=>\"5331d541f4eec77185000003\" }" the problem starts when I add a subscriber block to that channel in other class (listener class) like the following class OtherClass $redis.subscribe('channel') do |payload| p payload end end

Get sidekiq to execute a job immediately

故事扮演 提交于 2019-11-29 02:48:04
At the moment, I have a sidekiq job like this: class SyncUser include Sidekiq::Worker def perform(user_id) #do stuff end end I am placing a job on the queue like this: SyncUser.perform_async user.id This all works of course but there is a bit of a lag between calling perform_async and the job actually getting executed. Is there anything else I can do to tell sidekiq to execute the job immediately? There are two questions here. If you want to execute a job immediately, in the current context you can use: SyncUser.new.perform(user.id) If you want to decrease the delay between asynchronous work

Rails: Cancelling a scheduled job in Sidekiq

那年仲夏 提交于 2019-11-29 00:10:53
So I have a Sidekiq worker in my model which looks like this: class Perk < ActiveRecord::Base include Sidekiq::Worker include Sidekiq::Status::Worker after_save :update_release_time def update_release_time if self.release_time_changed? #if scheduled job already exists then cancel and reschedule # Sidekiq::Status.cancel scheduled_job_id # scheduled_job_id = NotifierWorker.perform_at(time.seconds.from_now, .....) #elsif scheduled job doesn't exist, then schedule for the first time # scheduled_job_id = NotifierWorker.perform_at(time.seconds.from_now, .....) #end end end end So basically, my code

What is the best way to use Redis in a Multi-threaded Rails environment? (Puma / Sidekiq)

被刻印的时光 ゝ 提交于 2019-11-28 20:18:24
I'm using Redis in my application, both for Sidekiq queues, and for model caching. What is the best way to have a Redis connection available to my models, considering that the models that will be hitting Redis will be called both from my Web application (ran via Puma), and from background jobs inside Sidekiq? I'm currently doing this in my initializers: Redis.current = Redis.new(host: 'localhost', port: 6379) And then simply use Redis.current.get / Redis.current.set (and similar) throughout the code... This should be thread-safe, as far as I understand, since the Redis Client only runs one

Redis raise error: NOAUTH Authentication required but there is no password setting

依然范特西╮ 提交于 2019-11-28 19:09:46
I got error NOAUTH Authentication required when I connect to Redis server via command: redis-cli and run ping to check if Redis is working. I found answer for NOAUTH Authentication required error which describes that this error only happens when Redis is set a password, but I checked Redis config file at etc/redis/redis.conf and there is no password setting. Does anyone know that if there are other settings which can cause this error? Thanks for any help. p/s: I am using Ruby on Rails web framework, Redis database is used for Sidekiq. Edited: Redis version is 2.8.4. Server is hosted on AWS.

Sidekiq: Ensure all jobs on the queue are unique

会有一股神秘感。 提交于 2019-11-28 18:57:50
I have some update triggers which push jobs onto the Sidekiq queue. So in some cases, there can be multiple jobs to process the same object. There are a couple of uniqueness plugins ( "Middleware" , Unique Jobs ), they're not documented much, but they seem to be more like throttlers to prevent repeat processing ; what I want is a throttler that prevents repeat creating of the same jobs. That way, an object will always be processed in its freshest state. Is there a plugin or technique for this? Update: I didn't have time to make a middleware, but I ended up with a related cleanup function to