puma: Conditional port is ignored in puma.rb
When I put a conditional for the port value it seems to get ignored and 5000 is used. When I define the port explicitly it works. Here is my puma.rb, the ENV['PORT']
is not defined in this case, running locally.
When I do port 3001
it works.
Using Puma 3.0.2
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3001
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
if defined?(Resque)
Resque.redis = ENV["<redis-uri>"] || "redis://127.0.0.1:6379"
end
end
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 20 (15 by maintainers)
Commits related to this issue
- Reverse the order of fetching data from config to make puma config is source of truth and return value from it first, if present Fixes #939 — committed to vipulnsward/puma by vipulnsward 8 years ago
- [webui] Run puma on port 3000 in dev After we switched from unicorn to puma in #5284, the rails development server started to run on port 5000. This is caused by foreman as it sets the environment v... — committed to ChrisBr/open-build-service by ChrisBr 6 years ago
hey @omitter we’re fixing this via https://github.com/rails/rails/pull/28137
This works for me
Are you using Puma 3.0 or above?
Related https://github.com/rails/rails/issues/24435#issuecomment-205875323 rails server, does not support it. running
puma
directly will.{:env=>nil}
It seemed to be working for a while, is the port cached somewhere and it’s not getting reset upon start/stop of server?