当我运行“rails server"(就像 Thin 一样)时,如何让“puma"自动启动 [英] How do I get 'puma' to start, automatically, when I run `rails server` (like Thin does)

查看:42
本文介绍了当我运行“rails server"(就像 Thin 一样)时,如何让“puma"自动启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当您运行 rails server 时,它会启动 Webrick.如果您安装瘦"gem,则改为瘦".我想对美洲狮"服务器做同样的事情.

Normally, when you run rails server it starts Webrick. If you install the 'thin' gem, then 'thin' starts instead. I would like to do the same thing with the 'puma' server.

我看到 railties (lib/rails/commands) 中的 start 命令调用 super,但我找不到super"的各种选项是什么.我还在瘦"中查看了许多对 Rails 的引用.

I see that the start command within railties (lib/rails/commands) calls super, but I can't find what the various options for 'super' are. I have also reviewed many references to Rails within 'thin'.

我在 2008 年 10 月发现了一个名为为脚本/服务器添加了瘦支持.#488 [Bob Klosinski]"的更新日志条目,但自那次提交 (a93ea88c0623b4f65af98c0eb55924c335bb3ac1) 以来,该代码区域发生了重大变化.

I found a Changelog entry entitled "Added Thin support to script/server. #488 [Bob Klosinski]" from Oct. of 2008, but that code area has changed significantly since that commit (a93ea88c0623b4f65af98c0eb55924c335bb3ac1).

如果有人可以将我引导到正确的代码部分,那将非常有帮助.

If someone could direct me to the right section of code, that would be very helpful.

推荐答案

经过一番挖掘,我找到了这个答案:https://stackoverflow.com/a/14911994/604526

After some digging, I've found this answer: https://stackoverflow.com/a/14911994/604526

要使 Puma 成为默认值,请将此代码粘贴到上面 require 'rails/commands' 的脚本/rails 中:

To make Puma the default, paste this code into script/rails above require 'rails/commands':

require 'rack/handler'
Rack::Handler::WEBrick = Rack::Handler.get(:puma)

Puma 现在是默认服务器,如果你使用 rails s

Puma is the default server now if you use rails s

rails s
=> Booting Puma
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Connecting to database specified by database.yml
Puma 1.6.3 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:3000

Rails 4

使用 Rails 4,您只需将 puma-gem 添加到 Gemfile.(使用 Rails 4.0.2 和 Puma 2.6.0 测试)

Rails 4

With Rails 4 you simply have to add the puma-gem to the Gemfile. (Tested with Rails 4.0.2 and Puma 2.6.0)

这篇关于当我运行“rails server"(就像 Thin 一样)时,如何让“puma"自动启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆