ruby-shoryuken / shoryuken

A super efficient Amazon SQS thread based message processor for Ruby. This project is in MAINTENANCE MODE. Reach me out on Slack link on the description if you want to become a new maintainer.
Other
2.06k stars 280 forks source link

Environment Variables in *.yml files are not resolved #728

Closed girishgl closed 1 year ago

girishgl commented 1 year ago

I am not able to read environment variables from yml file while starting shoryuken worker

bundle exec shoryuken --daemon --pidfile '/tmp/pids/shoryuken.pid' --logfile '/app/log/application.log' --config "/app/config/shoryuken.$RAILS_ENV.yml" --rails

shoryuken.production.yml


aws:
  region: us-east-1
  ssl_verify_peer: false
concurrency: 64
delay: 5
queues:
  - <%= ENV["XYZ_QUEUE"] %>
  - <%= ENV["ABC_QUEUE"] %>

These environments variables are set in config/application.rb

# load environment variables from .env files
require 'dotenv'
Dotenv.load

Dotenv.load('.env.test') if ENV['RAILS_ENV'] == 'test'

require 'aws-sdk-secretsmanager'
client = Aws::SecretsManager::Client.new(region: ENV['AWS_SECRET_MANAGER_REGION']  )

secrets_path = "xyz/#{ENV['RAILS_ENV']}".downcase
secrets = client.get_secret_value(secret_id: secrets_path).secret_string
JSON.parse(secrets).each_pair { |k, v| ENV["#{k}".upcase] = v }
matt-taylor commented 1 year ago

Hi @girishgl

Can you please provide more context:

(side note, 64 concurrency is very high)

girishgl commented 1 year ago

These are not included in .env file. these env are updated from Secret manager as below:

load environment variables from .env files require 'dotenv' Dotenv.load

require 'aws-sdk-secretsmanager' client = Aws::SecretsManager::Client.new(region: ENV['AWS_SECRET_MANAGER_REGION'] )

secrets_path = "xyz/#{ENV['RAILS_ENV']}".downcase secrets = client.get_secret_value(secret_id: secrets_path).secret_string JSON.parse(secrets).each_pair { |k, v| ENV["#{k}".upcase] = v }

and we run 74 delayed job workers as well on the same machine

girishgl commented 1 year ago

Hi Any updates here?

github-actions[bot] commented 1 year ago

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.

github-actions[bot] commented 1 year ago

This issue was closed because it hasn't seen activity for a while.