Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting Rails app through foreman doesn't load ENV vars on config/puma.rb file #286

Open
vfonic opened this issue Dec 31, 2021 · 0 comments

Comments

@vfonic
Copy link

vfonic commented Dec 31, 2021

Hi!

I'm using foreman gem to start my Rails app like this:
foreman start -f Procfile.dev

In Procfile.dev the line that starts Rails server looks like this:
backend: bundle exec puma -C config/puma.rb

And config/puma.rb looks like this:

# frozen_string_literal: true

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 1)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

If I add some puts in there:

# frozen_string_literal: true

puts ENV['WEB_CONCURRENCY']
puts ENV['RAILS_MAX_THREADS']
puts ENV['RAILS_ENV']
puts ENV['PORT']
puts ENV['RAILS_MIN_THREADS']

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 1)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

I can see that only ENV['PORT'] is set to 5000. All the other ENV vars are nil.

Any ideas what could be the issue here?

If I start Rails via rails s, the ENV vars are all set.

PS The ENV vars are set in the rest of the app, even when I start the app through foreman, it's only that in config/puma.rb the ENV vars are not set. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant