[英]puma initializer does not work with rails 4.2
我之前安装过很多次puma,而且从未遇到过此问题。 我逐字遵循了Heroku的指示。 我已经在其中创建了一个Procfile
:
web: bundle exec puma -C config/puma.rb
这是配置文件puma.rb:
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'] || 3000
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
end
当我通过运行rails s
或rails s puma
启动服务器时,我得到了
=> Booting Puma
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/david/projects/abc/config/initializers/puma.rb:1:in `<top (required)>': undefined method `workers' for main:Object (NoMethodError)
发生了什么事,我该如何解决? 我在开发中使用sqlite3,在生产中使用postgresql,但在两种环境中都遇到相同的错误。 我正在使用Rails 4.2.0和ruby 2.2.0。
您的Gemfile中必须有gem 'puma'
编辑:puma.rb不应位于初始化文件夹中,而应位于config文件夹中。 谢谢尼古拉
puma.rb
不应位于初始化文件夹中,而应位于config文件夹中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.