1
votes

I'm writing project with rails 4.2.5, sidekiq 4.0.2 and sidekiq_mailer 0.0.8. Currently I'm developing a feature to send emails asynchronously.

So, here is my mailer:

class UserMailer < ActionMailer::Base
  include Sidekiq::Mailer

  sidekiq_options queue: 'mailer', backtrace: true

  default from: '<mail_from>'

  def one_c_client_problems_email(message)
    @message      = message
    email_subject = "SUBJ"

    mail(to: '<mail_to>', subject: email_subject)
  end
end

Sidekiq initializer:

require 'sidekiq'
require 'sidekiq/web'

Sidekiq::Web.use(Rack::Auth::Basic) do |user, password|
  [user, password] == ['<login>', '<pass>']
end

schedule_file = 'config/schedule.yml'

if File.exists?(schedule_file) && Sidekiq.server?
  Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
end

Sidekiq config file:

---
:concurrency: 10
:pidfile: tmp/pids/sidekiq.pid
:logfile: log/sidekiq.log
:queues:
  - default
  - mailer

(I kick off sidekiq with bundle exec sidekiq -C config/sidekiq.yml command)

In application.rb, sidekiq is configured as default active job adapter:

config.active_job.queue_adapter = :sidekiq

When I try to send letter from rails console without sidekiq:

UserMailer.one_c_client_problems_email('message').deliver!

It works!

When I try to send async email with sidekiq:

UserMailer.one_c_client_problems_email('message').deliver

Nothing happens...

P.S. Periodical jobs works fine and non-mail jobs works fine. Why it is not working? Please, help!

No queues in Sidekiq UI:

no queues in sidekiq UI O_o

But UI see queues which should be initialized:

first tab

Sidekiq logs are empty (when I run sidekiq just with sidekiq -q default -q mailers console output are empty too). What I see in logs:

2016-03-17T09:26:33.926Z 1852 TID-ovlvb5ofs INFO: Booting Sidekiq 4.0.2 with redis options {:url=>nil}
2016-03-17T09:26:33.954Z 1852 TID-ovlvb5ofs INFO: Cron Jobs - add job with name: 1C Client. Update users to our db. Every hour
2016-03-17T09:26:33.956Z 1852 TID-ovlvb5ofs INFO: Cron Jobs - add job with name: Survey Reminder. Remind users about unfilled surveys. 9AM every day
2016-03-17T09:26:33.995Z 1852 TID-ovlvb5ofs INFO: Cron Jobs - add job with name: 1C Client. Update users to our db. Every hour
2016-03-17T09:26:33.997Z 1852 TID-ovlvb5ofs INFO: Cron Jobs - add job with name: Survey Reminder. Remind users about unfilled surveys. 9AM every day
2016-03-17T09:26:36.245Z 1852 TID-ovlvb5ofs INFO: Running in ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
2016-03-17T09:26:36.245Z 1852 TID-ovlvb5ofs INFO: See LICENSE and the LGPL-3.0 for licensing details.
2016-03-17T09:26:36.245Z 1852 TID-ovlvb5ofs INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
2016-03-17T09:26:36.245Z 1852 TID-ovlvb5ofs INFO: Starting processing, hit Ctrl-C to stop

Why in logs Booting Sidekiq 4.0.2 with redis options {:url=>nil} Redis URL is nil? Why sidekiq does not see redis?

1
have you enabled the Sidekiq-UI in your app? If yes, navigate to /sidekiq or look under ./logs/sidekiq.log and check if you find any stack tracesTilo
@Tilo yes, UI is enabled. On the UI I don't see my queues, I don't see in sidekiq.log that sidekiq see tasks...bmalets
logs and screens are attachedbmalets

1 Answers

1
votes

In Gemfile line gem 'rspec-sidekiq' should be in group :test.

This gem changes sidekiq configurations and works bad with Sidekiq 4.X.X versions.

group :test do
  gem 'rspec-sidekiq'
end

But I still don't know why redis URL is nil in logs...

Also, sidekiq 4.0.2 does not need sidekiq_mailer gem for async mail delivering.