Sub*_*ree 15 ruby-on-rails puma ruby-on-rails-4.1
我可以使用rails s puma或只是在rails中运行puma服务器puma.
根据这个答案,运行rails s puma使服务器知道rails环境.它显示puma单独运行的服务器错误等.
我想像这样设置一个配置文件:
配置/ 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'
...
Run Code Online (Sandbox Code Playgroud)
如果我运行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?
Run Code Online (Sandbox Code Playgroud)
我也尝试config/puma/development.rb按照puma文档放置配置文件.
感谢任何帮助:)
Rob*_*her 13
这是不可能用来rails s puma加载你的puma配置文件,如https://github.com/puma/puma/issues/512所示,你可能想在这里看一个类似的问题我怎么得到'美洲狮'当我运行`rails server`(像Thin一样)时,自动启动,讨论这个问题
小智 7
我发现使用Foreman(https://github.com/ddollar/foreman)是一个很好的解决方法,并提供额外的灵活性.
Heroku为此编写了一个很好的指南(https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server).下面是一个非常快速的入门.
第1步:安装Foreman.下面的Mac OS X示例,Foreman站点的完整指南
$ brew install foreman
Run Code Online (Sandbox Code Playgroud)
第2步:将其添加到您的Gemfile:
gem 'puma'
Run Code Online (Sandbox Code Playgroud)
第3步:创建一个名为Procfile的文件:
web: bundle exec puma -C config/puma.rb
Run Code Online (Sandbox Code Playgroud)
第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
Run Code Online (Sandbox Code Playgroud)