title: How to get Sidekiq workers running on Heroku
body: <p>I've set up Sidekiq with my Rails project.  It's running on Heroku with Unicorn.  I've gone through all the configuration steps including setting the proper REDISTOGO_URL (<a href="https://stackoverflow.com/questions/13770713/starting-sidekiq-on-heroku">as this question references</a>), I've added the following to my after_fork in unicorn.rb:</p>
  
  <pre><code>after_fork do |server,worker|
      if defined?(ActiveRecord::Base)
          ActiveRecord::Base.establish_connection
          Rails.logger.info('Connected to ActiveRecord')
      end
  
      Sidekiq.configure_client do |config|
          config.redis = { :size =&gt; 1 }
      end
  end
  </code></pre>
  
  <p>My Procfile is as follows:</p>
  
  <pre><code>web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
  worker: bundle exec sidekiq
  </code></pre>
  
  <p>Right now I call my worker to perform_async and it adds the task to the queue.  In fact in my Sidekiq web interface it says there are 7 items in the queue and it has all of the data there.  Yet there are no workers processing the queue and for the life of me, I can't figure out why.  If I run </p>
  
  <pre><code>heroku ps
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>=== web: `bundle exec unicorn -p $PORT -c ./config/unicorn.rb`
  web.1: up 2012/12/09 08:04:24 (~ 9m ago)
  
  === worker: `bundle exec sidekiq`
  worker.1: up 2012/12/09 08:04:08 (~ 10m ago)
  </code></pre>
  
  <p>Anybody have any idea what's going on here?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here's the code for my worker class.  Yes, I'm aware that the Oj gem has some issues potentially with sidekiq, but figured I'd give it a shot first.  I'm not getting any error messages at this point (the workers don't even run).</p>
  
  <pre><code>require 'addressable/uri'
  class DatasiftInteractionsWorker
  include Sidekiq::Worker
  sidekiq_options queue: "tweets"
  
  def perform( stream_id , interactions )
      interactions = Oj.load(interactions)
      interactions.each{ |interaction|
          if interaction['interaction']['type'] == 'twitter'
              url = interaction['links']['normalized_url'] unless interaction['links']['normalized_url'][0].nil?
              url = interaction['links']['url'] if interaction['links']['normalized_url'][0].nil?
              begin
                  puts interaction['links'] if url[0].nil?
                  next if url[0].nil?
                  host = Addressable::URI.parse(url[0]).host
                  host = host.gsub(/^www\.(.*)$/,'\1')
                  date_str = Time.now.strftime('%Y%m%d')
                  REDIS.pipelined do
                      # Add domain to Redis domains Set
                      REDIS.sadd date_str , host
                      # INCR Redis host
                      REDIS.incr( host + date_str )
                  end
              rescue
                  puts "ERROR: Could not store the following links: " + interaction['links'].to_s
              end
          end
      }
  end
  end
  </code></pre>