我之前已多次安装过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。
答案 0 :(得分:1)
您的Gemfile中需要gem 'puma'
编辑:puma.rb不应位于initializers文件夹中,而应位于config文件夹中。谢谢Nicolai
答案 1 :(得分:0)
puma.rb
不应位于initializers文件夹中,而应位于config文件夹