puma 初始化程序不适用于 Rails 4.2

2024-06-28

我之前安装过很多次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 or rails s puma i get

=> 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。


你需要有gem 'puma'在你的 Gemfile 中

编辑: puma.rb 不应位于初始值设定项文件夹中,而应位于 config 文件夹外部。谢谢尼古拉

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

puma 初始化程序不适用于 Rails 4.2 的相关文章

随机推荐