【问题标题】:Can not access production env rails app running local on localhost:3000无法访问在 localhost:3000 上本地运行的生产环境 rails 应用程序
【发布时间】:2020-01-27 05:45:22
【问题描述】:

我可以在开发中很好地运行我的 rails 应用程序:

rails s 然后转到 localhost:3000

但是,我需要测试生产并尝试过

rails s -e production,但是,当我转到 localhost:3000 时,我发现我的 rails 服务器没有任何反应。

=> Booting Puma
=> Rails 5.2.3 application starting in production 
=> Run `rails server -h` for more startup options
Set localhost 3000 as the default_url_option ----
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: production
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

为什么我无法访问我的生产 Rails 应用程序?有没有关于如何在本地机器上运行生产环境的具体教程?我正在使用 Mac OSX High Sierra。

【问题讨论】:

  • 在浏览器上,是否出现错误?如何知道“看到”您的 Rails 服务器上没有任何反应?
  • 注释输出到我启动服务器的终端
  • 有一段时间没用过rails了,也许在生产模式下只记录错误?当您尝试访问服务器 url 时,浏览器中的结果是什么?
  • rails s -e production -b 0.0.0.0 呢?

标签: ruby-on-rails ruby ruby-on-rails-5 production-environment


【解决方案1】:

我不相信 rails 在生产环境中会像在开发环境中那样记录对控制台的请求,所以您应该不会看到任何事情发生。

在启动服务器之前尝试运行rake assets:precompile。此外,请确保您已经为生产环境创建了一个数据库,并且您已经进行了迁移。你可以像这样创建数据库:rake db:create RAILS_ENV=production,然后像这样迁移rake db:migrate RAILS_ENV=production

如果您在让应用程序在生产环境中运行时仍然遇到问题,请检查生产日志。

【讨论】:

    猜你喜欢
    • 2020-08-04
    • 1970-01-01
    • 1970-01-01
    • 2015-04-23
    • 1970-01-01
    • 2021-01-26
    • 2014-11-18
    • 2017-09-11
    • 2021-02-09
    相关资源
    最近更新 更多