将Rails引擎添加到Procfile?

时间:2015-11-02 07:26:00

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

所需的方案是在部署到Heroku时在单独的dyno或dynos上运行Engine。 Procfile看起来像:

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

这样我们就可以轻松地缩放引擎使用的动力学:heroku ps:scale engine=3

这可能吗?

1 个答案:

答案 0 :(得分: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/

基本上我们需要标记我们的引擎。在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 将如下所示:

{{1}}