本文介绍了如何使用'rails s puma'通过配置文件运行rails puma服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 rails s puma 或仅使用 puma 在 rails 中运行 puma 服务器.

I am able to run a puma server in rails using either rails s puma or just puma.

根据这个答案,运行rails s puma 使服务器知道rails环境.它显示服务器错误等,而单独运行 puma 不会.

According to this answer, running rails s puma makes the server aware of the rails environment. It shows server errors etc that running puma alone does not.

我想像这样设置一个配置文件:

I want to set a config file like so:

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,我将无法弄清楚如何为 puma 提供选项.我尝试了以下方法:

If I run puma -C config/puma.rb everything works. However if I run rails s puma I can't work out how to give options to puma. I have tried the following:

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.rbrel="nofollow noreferrer">美洲狮文档.

I have also tried putting the config file at config/puma/development.rb as per the puma docs.

感谢您对此的任何帮助:)

Appreciate any help on this :)

推荐答案

不能使用 rails s puma 来加载你的 puma 配置文件,这里确认了 https://github.com/puma/puma/issues/512,你可能想看看类似的问题在这里 当我运行rails server"(就像 Thin 一样)时,如何让puma"自动启动,这里讨论了这一点

It is not possible to use rails s puma to load your puma configuration file, as confirmed here https://github.com/puma/puma/issues/512, you might want to take a look at a similar question here How do I get 'puma' to start, automatically, when I run `rails server` (like Thin does) where this is discussed

这篇关于如何使用'rails s puma'通过配置文件运行rails puma服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 06:30