sidekiq

Circular dependency when Starting Sidekiq Queue

一笑奈何 提交于 2020-01-02 12:40:13
问题 I get the following error when loading a sidekiq queue: RuntimeError: Circular dependency detected while autoloading constant FileProcessor /Users/johnmcauley/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:492:in `load_missing_constant' /Users/johnmcauley/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing' /Users/johnmcauley/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:526

Sidekiq VS. RabbitMQ

时光怂恿深爱的人放手 提交于 2020-01-02 02:45:06
问题 We are in need of a queuing system in our Ruby On Rails 4 web application what are the differences and why would/wouldn't you pick Sidekiq over RabbitMQ ? 回答1: It's quite different things with different usage. Sidekiq is full-featured solution for job queueing and processing, while RabbitMQ is just a message broker where you can build your own stuff upon it. 来源: https://stackoverflow.com/questions/34525941/sidekiq-vs-rabbitmq

sidekiq to cancel list to scheduled jobs

跟風遠走 提交于 2020-01-01 08:03:33
问题 I have several scheduled jobs running like this: MyWorker.perform_at(3.hours.from_now, 'mike', 1) I am wondering, if later, say an hour later, I feel like I want to cancel this job, how would I go about doing that? 回答1: I've recently written a bit of code to handle this, it's available in my branch of the sidekiq-status gem. You can view it, or use it here: https://github.com/Robinson7D/sidekiq-status (You would have to use that as the git: information in the gemfile, currently, until the

Run Sidekiq as daemon on Ubuntu

懵懂的女人 提交于 2019-12-31 18:57:08
问题 How can I run sidekiq as daemon on Ubuntu? If I run bundle exec sidekiq -D I get invalid option: -D , is there any way to run it without some other controller, like god, upstart...? 回答1: there's an option to Daemonize sidekiq, just pass -d option commit 回答2: Running as daemon won't restart the sidekiq if it crashes unexpectedly. One alternate way could be to run sidekiq as a service (An upstart job). If the system is rebooted than also the upstart job will run sidekiq. Here is the complete

Gracefully shutting down sidekiq processes

◇◆丶佛笑我妖孽 提交于 2019-12-31 07:56:32
问题 Does anyone know how to find sidekiq's pidfile to gracefully shut it down? Running ps ax | grep sidekiq and then running sidekiqctl stop <pid from grep> consistently gives a no such pidfile error? Cntl-C and Cntl-D also seem to have no effect. Closing the process window and reopening a new window doesn't kill the process as it appears to be running as a daemon. The only consistent fix I've found is rebooting. 回答1: Use this to kill sidekiq forcefully. ps -ef | grep sidekiq | grep -v grep | awk

Stack level too deep when using carrierwave versions

不问归期 提交于 2019-12-30 04:06:23
问题 I'm trying to use a sidekiq worker, which more or less saves a image file to database (using carrierwave). There are few files to save, which are a keyframes extracted from a video file. That's what that worker is about. My image uploader has a few versions defined and looks as follows: class KeyframeUploader < CarrierWave::Uploader::Base # ... # Keyframe thumbnail sizes version :small do process resize_to_fill: [180, 180], if: :square? process resize_to_fill: [320, 180], if: :not_square? end

Mailer unable to access reset_token in User model

懵懂的女人 提交于 2019-12-29 09:12:00
问题 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

Rails background worker always fails first time, works second

拈花ヽ惹草 提交于 2019-12-25 13:19:19
问题 I have a sidekiq worker that fires after an object is saved: class Post < ActiveRecord::Base attr_accessible :description, :name, :key after_save :process def process ProcessWorker.perform_async(id, key) if key.present? end def secure_url key.match(/(.*\/)+(.*$)/)[1] end def nonsecure_url key.gsub('https', 'http') end end The worker looks like the following (it's not complete yet... just testing): class ProcessWorker include Sidekiq::Worker def perform(id, key) post = Post.find(id) puts post

Rails & Sidekiq: Confused about Debounce

£可爱£侵袭症+ 提交于 2019-12-25 08:57:10
问题 I'm building a Tinder style app where users can swipe through events. Currently, I have a background job that is being fired any time a user swipes an event. With users swiping through 20 events per minute, I'm creating a ton of background jobs: worker.rb class Worker include Sidekiq::Worker def perform(user_id, newly_voted_event_id) user = User.find(user_id) event = Event.find(newly_voted_event_id) events_to_rerank = event.similar.unvoted(user_id) events_to_rerank.each do |e| e.rank(user_id)

Periodically checking if a sidekiq job has been cancelled

ぐ巨炮叔叔 提交于 2019-12-24 07:59:02
问题 Jobs in sidekiq are suppose to check if they have been cancelled, but if I have a long running job, I'd like for it to check itself periodically. This example does not work : I've not wrapped the fake work in any sort of future within which I can raise an exception -- which I'm not sure is even possible. How might I do this? class ThingWorker def perform(phase, id) thing = Thing.find(id) # schedule the initial check schedule_cancellation_check(thing.updated_at, id) # maybe wrap this in