o..o
o..o

Reputation: 1921

Why is Sidekiq running in development environment on server?

in my nginx website config file (/etc/nginx/sites-available/my_website I have set:

passenger_env_var RAILS_ENV staging;

I'm using Sidekiq for sending emails, starting it like this:

bundle exec sidekiq -q mailers -d -L log/sidekiq.log

but my Sidekiq is having environment set to development. Why?

Do I have to set the environment explicitly when starting sidekiq? I thought it is set by the nginx config.

Thanks

Upvotes: 0

Views: 3929

Answers (2)

It could be configured by creating a file under initializers/sidekiq.rb

If Rails.env.development?
  Sidekiq.configure_server do |config|
    config.redis = { url: 'redis://localhost:6379/0', namespace: "name_{Rails.env}" }
  end

  Sidekiq.configure_client do |config|
    config.redis = { url: 'redis://localhost:6379/0', namespace: "name_{Rails.env}" }
  end
elsif Rails.env.staging?
  Sidekiq.configure_server do |config|
    config.redis = { url: 'redis://redis-xx.xxxx.xxxx.xx.xxx.amazonaws.com:6379/12', namespace: "name_#{Rails.env}" }
  end

  Sidekiq.configure_client do |config|
    config.redis = { url: 'redis://redis-xx.xxxx.xxxx.xx.xxx.amazonaws.com:6379/12', namespace: "name_#{Rails.env}" }
  end
end

Upvotes: 2

muzychuk
muzychuk

Reputation: 298

Sidekiq's default environment is development. One way to set it is to run sidekiq like this

bundle exec sidekiq --environment production

Upvotes: 4

Related Questions