Question: Sidekiq + ActionJob with ActionCable in production mode

Question

Sidekiq + ActionJob with ActionCable in production mode

Answers 0
Added at 2016-10-03 15:10
Tags
Question

My stack Rails 5, ActionCable, ActiveJob, Sidekiq 2.2 and Redis. In development mode all work correct. In production with Sidekiq and Redis ActiveJob doesn't work.

Source code:

#notification_channel
def execute(data)
  act = data['act']
  data['current_profile'] = current_profile
  data['profile'] = Profile.find(data['profile']); 
  follow_unfollow(act, data['profile'])
  NotificationJob.perform_later act, data
end


#NotificationJob
class NotificationJob < ApplicationJob
  queue_as :default

  def perform(type, data)
    begin
      #some code
      ActionCable.server.broadcast "notifications_channel_#{data['profile'].id}", params
    rescue => e
      logger.error(e.message.red + "\n")
      logger.error(e.backtrace.inspect.red + "\n")
    end
  end

end

Cable configs:

#config/cable.yml
production:
  adapter: redis
  url: redis://localhost:6379/1

Sidekiq Configs:

 #config/initializers/sidekiq.rb
 Sidekiq.configure_server do |config|
   config.redis = { :url => 'redis://localhost:6379/1', :namespace => my_namespace }
 end

 Sidekiq.configure_client do |config|
   config.redis = { :url => 'redis://localhost:6379/1', :namespace => my_namespace }
 end

In production log I see:

#production.log
D, A LOT OF ACTIONS FROM notification_channel
I, [2016-10-03T00:00:11.535425 #8897]  INFO -- : [ActionCable] [tag] [ActiveJob] Enqueued NotificationJob (Job ID: eb93ed75-a8f3-488d-ac1a-ccd6656d2a7c) to Sidekiq(my_namespace_default) with arguments: "follow", {"act"=>"follow", ...other_params...}

Sidekiq log contains only info about Booting, has no message about some actions.

Please help me!

Answers to

Sidekiq + ActionJob with ActionCable in production mode

Source Show
◀ Wstecz