【问题标题】:Add Rails Engine to Procfile?将 Rails 引擎添加到 Procfile?
【发布时间】:2015-11-02 07:26:00
【问题描述】:

所需的场景是在部署到 Heroku 时在单独的 dyno 或 dyno 上运行引擎。 Procfile 看起来像:

web: bundle exec rails server -p $PORT
worker: bundle exec rake jobs:work
engine: TODO

这样我们可以轻松扩展引擎使用的测功机:heroku ps:scale engine=3

这可能吗?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 heroku rails-engines foreman


    【解决方案1】:

    这个问题在这里得到了回答:https://groups.google.com/forum/#!topic/components-in-rails/zQTLPZGqIaI

    最终听从了 Enrico Teotti 在这篇文章中的建议:http://teotti.com/feature-flagging-portions-of-your-ruby-on-rails-application-with-engines/

    基本上我们需要对我们的引擎进行功能标记。在routes.rb

    Rails.application.routes.draw do
      case ENV['APP_RUNNING_MODE']
      when 'my_engine'
        mount MyEngine::Engine => "/my_engine"
      else
        # rest of the routes...
      end
    end
    

    Procfile 看起来像:

    web: bundle exec rails server -p $PORT
    worker: bundle exec rake jobs:work
    engine: APP_RUNNING_MODE=my_engine bundle exec rails server -p $PORT
    

    【讨论】:

    • 非常有趣的解决方案!您是如何设法在同一个端口上公开两个 Rails 服务器以使其可以在外部访问的?附带说明一下,如果 Procfile 的 : 部分在运行时在环境变量中可用,则一个不错的功能将是,因此您无需像在 APP_RUNNING_MODE 中那样明确说明它。继续摇摆!
    • 嘿@fagiani 抱歉回复晚了。刚刚检查过,我们使用相同的端口,但在不同的 Heroku 应用程序上。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 2014-05-25
    • 2018-05-22
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多