Reputation: 48493
We have added a few weeks ago monitoring user activity in our system, something like this:
class ApplicationController < ActionController::Base
before_filter :log_request
def log_request
params_to_parse = params
all_params = params.except(:controller, :action).inspect.gsub("✓", "")
RequestLoggerWorker.perform_async(params[:controller],
params[:action],
(current_admin.nil? ? nil : current_admin.id),
request.method,
...)
end
end
The Sidekiq method:
class RequestLoggerWorker
include Sidekiq::Worker
def perform(...)
ActivityLog.create(admin_id: admin_id,
controller_log: controller,
...)
end
end
Through this mechanism, we save like 4,000 clicks a day. This part seems to be working well.
What we have noticed, though, that since the time we implemented this Sidekiq has blackouts - this morning twice. Actions that we using Sidekiq were not processed.
I needed to log in to our Ubuntu server (AWS EC2) and manually run Sidekiq (RAILS_ENV=production bundle exec sidekiq
).
What's causing shutting down Sidekiq? I am trying to research this, but I am not successful so far.
Our Sidekiq config (config/initializers/sidekiq.rb
):
Sidekiq.configure_server do |config|
config.redis = { url: "redis://deployer_redis@IP:6379/#{env_num}",
namespace: "sidekiq_myapp_com_#{Rails.env}" }
end
Sidekiq.configure_client do |config|
config.redis = { url: "redis://deployer_redis@IP:6379/#{env_num}",
namespace: "sidekiq_myapp_com_#{Rails.env}" }
end
As a temporary solution, I needed to turn off this morning the activity logging mechanism.
Every help will be appreciated.
Thank you.
Upvotes: 1
Views: 67
Reputation: 22228
You aren't starting Sidekiq as a proper system service so it runs 24/7. You need to integrate Sidekiq into Ubuntu's Upstart config.
https://github.com/mperham/sidekiq/wiki/Deployment#daemonization https://github.com/mperham/sidekiq/tree/master/examples/upstart
Upvotes: 3