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

uninitialized constant Puma::Cluster #1731

Closed
Fudoshiki opened this issue Feb 22, 2019 · 7 comments
Closed

uninitialized constant Puma::Cluster #1731

Fudoshiki opened this issue Feb 22, 2019 · 7 comments
Labels

Comments

@Fudoshiki
Copy link
Contributor

Fudoshiki commented Feb 22, 2019

Rails master 6.0.0.beta1
Puma master

puma.rb

max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
environment ENV.fetch('RAILS_ENV') { 'development' }
workers ENV.fetch('WEB_CONCURRENCY') { 2 }
bind ENV.fetch('PUMA_SOCK') { 'unix://tmp/sockets/puma.sock' }
state_path ENV.fetch('SERVER_STATE') { 'tmp/pids/puma.state' }
activate_control_app ENV.fetch('PUMACTL_SOCK') { 'unix://tmp/sockets/pumactl.sock' }
pidfile 'tmp/pids/puma.pid'
worker_timeout 10
plugin :tmp_restart
/usr/local/rvm/bin/rvm 2.6.1 do bundle exec pumactl -S ~/repository/shared/tmp/pids/puma.state -F ~/repository/current/config/puma.rb stop
uninitialized constant Puma::Cluster
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/lib/puma/dsl.rb:455:in `worker_timeout'
/srv/webapp/repository/current/config/puma.rb:69:in `_load_from'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/lib/puma/dsl.rb:43:in `instance_eval'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/lib/puma/dsl.rb:43:in `_load_from'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/lib/puma/configuration.rb:194:in `block in load'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/lib/puma/configuration.rb:194:in `each'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/lib/puma/configuration.rb:194:in `load'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/lib/puma/control_cli.rb:85:in `initialize'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/bin/pumactl:5:in `new'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bundler/gems/puma-0991396844fe/bin/pumactl:5:in `<top (required)>'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bin/pumactl:23:in `load'
/srv/webapp/repository/shared/bundle/ruby/2.6.0/bin/pumactl:23:in `<top (required)>'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:74:in `load'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:28:in `run'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/cli.rb:463:in `exec'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/cli.rb:27:in `dispatch'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/cli.rb:18:in `start'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/exe/bundle:30:in `block in <top (required)>'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/srv/webapp/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.1/exe/bundle:22:in `<top (required)>'
/srv/webapp/.rvm/gems/ruby-2.6.1/bin/bundle:23:in `load'
/srv/webapp/.rvm/gems/ruby-2.6.1/bin/bundle:23:in `<main>'
@evanphx evanphx added the bug label Mar 11, 2019
@MSP-Greg
Copy link
Member

The error (uninitialized constant Puma::Cluster) is from puma/dsl.rb:466, which is required by puma/configuration.

puma/lib/puma/dsl.rb

Lines 464 to 466 in ca03c52

def worker_timeout(timeout)
timeout = Integer(timeout)
min = Cluster::WORKER_CHECK_INTERVAL

The code causing the error was due to commit 64db36c, 'Enforce a minimum worker_timeout' on 2019-01-24.

With the error shown, the call stack starts with puma/control_cli

puma/control_cli.rb:242 (#start) which requires:
puma/cli                         which requires:
puma.launcher                    which requires:
puma/cluster

Options to fix:

  1. In control_cli, move require 'puma/cli' from the start method to the initialize method.

  2. In puma/dsl, add require 'puma/cluster' to the worker_timeout method.

  3. Adding require elsewhere.

@MSP-Greg MSP-Greg mentioned this issue Mar 19, 2019
@schneems
Copy link
Contributor

It looks like that line in the control_cli was added in 274350a about 6 years ago. I generally don't like having requires in methods unless there's a really good reason.

I don't see a downside to having the require be outside of the method and at the top of the file, though feel free to let me know if that causes issues.

@MSP-Greg
Copy link
Member

I generally don't like having requires in methods unless there's a really good reason.

Agreed. I didn't mention that puma/cli.rb requires puma, so I wasn't sure if it was a circular require issue. I haven't looked into all the various ways one can start Puma, so I left it alone.

puma/lib/puma.rb

Lines 11 to 14 in 2f57c8e

module Puma
autoload :Const, 'puma/const'
autoload :Server, 'puma/server'
autoload :Launcher, 'puma/launcher'

Since it's autoloading three files, maybe add :Cluster?

@schneems
Copy link
Contributor

schneems commented Mar 19, 2019

Can you try out a fix on a branch and we can see if the tests pass? I'm fine with an autoload, but it does seem like overkill for that one little constant. I think once we get this fix in then we can probably ship another version I'm working on a history.md now. Actually looks like there are other release plans.

@MSP-Greg
Copy link
Member

I'll give a try with Autoload. Dumb question - if we're autoloading Cluster, should the same be done with Single?

Actually looks like there are other release plans.

nio4r? etc?

@schneems
Copy link
Contributor

nio4r? etc?

Likely, a slightly more purposeful release rather than just the cobbled together remnants of master. Ideally targeting RailsConf timeframe.

schneems added a commit that referenced this issue Mar 20, 2019
Move WORKER_CHECK_INTERVAL const. Fixes #1731
@nateberkopec
Copy link
Member

We should probably just Zeitwerk everything for the future, eh?

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

No branches or pull requests

5 participants