我可以使用rails s puma或puma在rails中运行美洲狮服务器。
根据这个答案的说法,运行rails s puma使服务器了解rails环境。它显示了服务器错误等,仅运行puma并不能做到这一点。
我想设置一个配置文件如下:
config/puma.rb
workers Integer(ENV['PUMA_WORKERS'] || 3)
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
...如果我运行puma -C config/puma.rb,一切都会正常工作。但是,如果我运行rails s puma,我就无法找到给美洲狮提供选项的方法。我尝试了以下几点:
rails s puma # Puma server works but no config file is passed in.
rails s puma -C config/puma.rb # Invalid option -C
rails s puma -c config/puma.rb # Undefined method 'workers'. So rails is
# trying to use the config instead of puma?我还试着将配置文件按config/puma/development.rb设置为美洲狮医生。
(欢迎在这方面提供任何帮助:)
发布于 2014-08-10 04:55:30
不可能使用rails s puma加载您的puma配置文件,正如这里所确认的,https://github.com/puma/puma/issues/512,您可能希望在这里查看一个类似的问题,(就像Thin那样),在这里讨论这个问题。
发布于 2015-03-15 05:58:19
我发现使用Foreman (https://github.com/ddollar/foreman)是一个很好的解决办法,同时也提供了额外的灵活性。
Heroku为此写了一个很好的指南( https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server )。下面是一个非常快速的开始。
步骤1:安装Foreman。下面是Mac的示例,Foreman站点的完整指南
$ brew install foreman步骤2:将其添加到Gemfile中:
gem 'puma'步骤3:创建一个名为Procfile的文件:
web: bundle exec puma -C config/puma.rb步骤4:现在通过以下方法启动应用程序
$ foreman start
00:36:05 web.1 | started with pid 19869
00:36:05 web.1 | [19869] Puma starting in cluster mode...
00:36:05 web.1 | [19869] * Version 2.11.1 (ruby 2.2.1-p85), codename: Intrepid Squirrel
00:36:05 web.1 | [19869] * Min threads: 1, max threads: 1
00:36:05 web.1 | [19869] * Environment: development
00:36:05 web.1 | [19869] * Process workers: 1
00:36:05 web.1 | [19869] * Preloading application
00:36:07 web.1 | [19869] * Listening on tcp://0.0.0.0:3000
00:36:07 web.1 | [19869] Use Ctrl-C to stop
00:36:07 web.1 | [19869] - Worker 0 (pid: 19870) booted, phase: 0发布于 2016-09-01 16:35:13
不幸的是你不能。今天,我不得不让Puma在我的dev环境中使用ssl,所以我在我的rails应用程序(Rails 5)中编辑了文件config/puma.rb,并添加了:
ssl_bind '127.0.0.1', '3000', {
key: 'path_to_you_key_file', #/Users/DevRuby/.ssh/server.key
cert: 'path_to_yout_cert_file', #/Users/DevRuby/.ssh/server.crt
verify_mode: 'none' #fix errors due to self-signed certificate
}并将下面一行添加到我的config/environments/development.rb中,以便将日志发送到STDOUT:
config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))我现在使用的不是使用#rails启动应用程序,而是使用#puma命令,它加载config/puma.rb配置文件中的所有设置。
https://stackoverflow.com/questions/25225444
复制相似问题