Does Heroku support ActionController::Live?

怎甘沉沦 提交于 2019-12-12 18:17:06

问题


I have a Rails app hosted on Heroku and I want to add Server Sent Events functionalities, but I can't find any documentation or blog post specific for Heroku.

As not all servers (e.g. WEBrick) support ActionController::Live I was wondering what is the default server on Heroku and whether is possible to configure the environment (i.e. change server) to support SSEs.

Any further advice about the server to use and how to configure would be greatly appreciated.


回答1:


I think my answer is not so widely helpfull, but you can try.

For the first thing:

create Procfile in rails root within the following content:

web: bundle exec rails server puma -p $PORT -e $RACK_ENV

then add to Gemfile:

gem 'puma'

In above you can switch to thin, but consider link below (and many more details)

http://tenderlovemaking.com/2012/07/30/is-it-live.html




回答2:


Heroku wouldn't necessarily be the issue here - it's an environment which allows your app to run (on Amazon EC2 I think)


Multi-Threaded Servers

The thing you've got to look for is the server software you use to run your app. Heroku basically takes your server gem & allows it to run with their processors, and other computing power; so it's really whether their platform can play ball with the right server

You're really looking for multi-threaded servers, which you can find here Is puma the ONLY multi-threaded rails 4 http server?

Puma

Rainbows! supports multiple concurrency models, including multithreading

Zbatery - Rack HTTP server without a fork stuck in it

Phusion Passenger 4 has supported multithreading since its beta stages

Thin does have a threaded mode which can be enabled by passing --threaded or by setting threaded: true in the appropriate configuration file (e.g. bundle exec thin start --threaded)

Net::HTTP::Server, despite the lack of advertising, supports multithreading; very minimalist



来源:https://stackoverflow.com/questions/17897944/does-heroku-support-actioncontrollerlive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!