I'm trying to use sidekiq to send emails asynchronously on a Hanami app. This is my worker class:
# lib/myapp/workers/async_mailers.rb
class AsyncMailer
include Sidekiq::Worker
def perform(mail_type)
...
# send mail
...
end
end
But when Sidekiq tries to start the worker it fails and gives the following message:
WARN: NameError: uninitialized constant MailWorker
I'm running sidekiq using the following comand in my Procfile:
bundle exec sidekiq -e development -r ./config/environment.rb
It seems like sidekiq cannot find my lib folder. I'm pretty new to Hanami and probably forgot to add some configuration somewhere, but I've been unable to figure out exactly what to do in order to solve this.
Doing some digging in the hanami comunity chat, I ended up figuring out that the correct way to invoke sidekiq with hanami is by using the boot.rb
file for configuration. So you should run it like this:
bundle exec sidekiq -e development -r ./config/boot.rb