简体   繁体   English

在 Ruby on Rails 应用程序中更新 Puma 后,开发服务器不工作

[英]Development server doesn't work after updating Puma in Ruby on Rails app

I'll preface this with letting you know that I'm quite a novice when it comes to programming, so I apologise if the solution is straightforward.我首先要让您知道我在编程方面还是个新手,所以如果解决方案很简单,我深表歉意。

I have a Ruby on Rails app on 'Codeanywhere' which is an Online cloud-based IDE, I'm using Puma to view the server in development.我在“Codeanywhere”上有一个 Ruby on Rails 应用程序,它是一个基于云的在线 IDE,我正在使用 Puma 查看正在开发的服务器。 Usually, it's as easy as entering in 'Rails s' and then clicking the preview button to view my app in development.通常,只需输入“Rails s”,然后单击预览按钮即可查看我正在开发的应用程序。

However, after doing a 'bundle update', this no longer works.但是,在进行“捆绑更新”后,这不再有效。 I enter in 'Rails s' and it says the server has started, but when I click the preview button, it says it can't connect and there's no server running.我输入“Rails s”,它说服务器已经启动,但是当我单击预览按钮时,它说它无法连接并且没有服务器在运行。 I've narrowed it down and the 'update' that is causing this issue is either the updating of the Rails gem itself, or more likely the updating of the Puma gem, which is the gem that controls this function.我已经缩小了范围,导致此问题的“更新”要么是 Rails gem 本身的更新,要么更可能是 Puma gem 的更新,它是控制此功能的 gem。

I've tried "rails s --binding=0.0.0.0" but that hasn't worked either, it seems to just be the update that breaks it, but I need the update as it's a security vulnerability.我试过 "rails s --binding=0.0.0.0" 但这也没有用,它似乎只是破坏它的更新,但我需要更新,因为它是一个安全漏洞。 If I roll back the update, it works fine, but I need the updated gems.如果我回滚更新,它工作正常,但我需要更新的宝石。

Rails version before update: 5.2.1 Puma version before update: 3.11更新前的 Rails 版本:5.2.1 更新前的 Puma 版本:3.11

Rails version after update: 5.2.4 Puma version after update: 3.12.2更新后的 Rails 版本:5.2.4 更新后的 Puma 版本:3.12.2

Rails S output is: Rails S 输出是:

=> Booting Puma
=> Rails 5.2.4 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.2 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
^C- Gracefully stop

Some insight would be greatly appreciated.一些见解将不胜感激。

I just hit this after updating to Puma 3.12.2, too (Rails 6 in case anyone cares).我也是在更新到 Puma 3.12.2 之后才点击的(Rails 6,以防有人关心)。

Reviewing lib/puma/dsl.rb , I found 2 ways to change my Rails app's config/puma.rb to specify 0.0.0.0 .查看lib/puma/dsl.rb ,我发现了 2 种更改 Rails 应用程序的config/puma.rb以指定0.0.0.0

Both两个都

set_default_host '0.0.0.0'
port        ENV.fetch("PORT") { 3000 }

and

port        ENV.fetch("PORT") { 3000 }, '0.0.0.0'

make it print让它打印

[...]
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
[...]

on startup and work/listen accordingly for me.在启动和工作/听我相应地。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM