Live chat on Rails app through Faye but on Passenger with Apache - ruby-on-rails

Our website is currently running our Rails web app on Passenger with Apache.
Recently, there is a requirement to do live chatting. As such we are planning to deploy Faye by following this article (http://code.tutsplus.com/tutorials/how-to-use-faye-as-a-real-time-push-server-in-rails--net-22600).
However, since Apache does not support websocket, we are not able to use any of such implementation.
We preferred not to change the webserver since additional effort for testing and migration will be involve. Is there any other way to get around this problem?
Appreciate any helps from Rails expert out that.
-Jax

Don't know the answer, though somewhere I read that you should use redis for faye to run it with apache/passenger beacuse they can't be run in single process and share memory, checkout faye-redis gem. Than probably faye server should be run as separate process, and Apache configured to send ':9292/faye' to it.

Related

Setting up Rails on Hostmonster

I'm able to run rails s through ssh successfully and see the app start up just as it does on my own machine but I'm unable to access the app from the web. The app is directly under the home folder and I have a symbolic link pointing from public_html to the public folder of my rails app, just as this tutorial explains. I even tried setting up a subdomain and every other step in the tutorial to no avail. Any help would be highly appreciated.
You need an application server like Phusion Passenger, Unicorn or puma to run a Ruby app in a production environment. Typically, you'll integrate the application server into a web server's (Apache, nginx) environment.
I don't know about your hoster, but if you have root access, then you can probably use any of these application servers.
The built-in server you start by running rails server is only meant for testing purposes on your local machine. It has not been made with security, performance, stability or any other production-environment criteria in mind.

Javascript not working in production: Nginx, Passenger, Rails on Ubuntu Server (Node.js?)

Do I need to install/config Node.js to get Javascript running?
Is this the simplest solution, seeing that my site has really low traffic?
Javascript doesn't seem to work for me but only in production for a site I am running. The site is setup on the latest version of Ubuntu Server, with Nginx and Passenger (it's a Ruby on Rails app). The site runs great and fast for the past few months, but Javascripts (in particular, things like Twitter Bootstrap's tooltip, etc.) don't run on this production server although they work in my testing/dev environments.
My thoughts are that Javascript is broken b/c I need to install/configure Node.js? I've seen Node.js mentioned in some deployment setup guides but can't find detailed info into if this is necessary.
My site is very low traffic (maybe 3-5 users at any time) for a small company website. The only reason I needed to setup my own web server is that I needed to run the app on the private company network to access certain resources.
By default your js/css don't compiled. You should precompile them.
You can run "bundle exec rake assets:precompile" on your computer and deploy compiled code to the server. Instead node.js you can use therubyracer gem.
For more information read rails guide

How to implement SPDY with Rails 3.2.2 on Heroku?

I'm hearing that SPDY is where things are likely headed, and I'd like to try to use it with a Rails site I'm running. I haven't been able to find any tutorials however, and the one gem I found doesn't seem to work (everyone is reporting the same error on it across all browsers).
Is it currently possible to implement SPDY on Heroku with a Rails app?
No, there is no way to get SPDY on Heroku today, although I do hope that will change in the future. Heroku has their own HTTP "routing fabric" which is fronted by nginx frontends. The nginx team is working on a SPDY module, but there is no hard date for its release yet. In addition, Heroku would need to install it on their frontends, etc -- in other words, it would require some careful coordination.
If you are interested in testing SPDY with Rails, I would recommend checking out mod_spdy for Apache. You should be able to use Passenger in conjunction with mod_spdy, although that would have to run outside of Heroku for now.
Try setting up CloudFlare an SPDY CDN/proxy service
You can set up a reverse proxy in front of your Heroku app.
One way to do it is using Dockhero addon.
Here's an example with SPDY / HTTP/2 / QUIC support to your Rails app hosted with Heroku - https://github.com/dockhero/quic-protocol-demo
Dockhero add-on is in Private Alpha as of September 2016, try it for free by signing up at https://dockhero.io/

Getting Sure you're not looking for /faye ? instead of my application on Heroku

This seems like it should be a simple problem. I'm trying to host my Rails 3.1 application that uses Faye on Heroku, but I keep getting this:
Sure you're not looking for /faye ?
I understand this is just the faye server responding to me. But why isn't it launching my application, and rather sending me to this? (I'm following parts of this application by the way)
Here's my faye.ru
require 'faye'
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
run faye_server
I also have a config.ru that's just the default config.ru file.
I'm pretty sure this is due to Heroku not allowing me to run the Faye server at the same time as the Rails server. I think the only real solution to this is running a separate web process through Heroku, which unforunately, costs about $35 a month.
If anyone finds out how to run these two processes without shelling out the $35 dollars a month, please let me know.
Run another Heroku project for faye, https://github.com/ntenisOT/Faye-Heroku-Cedar-RedisToGo
Other question on SO: Is it possible to host FAYE, on Heroku?
Well you answered your own question, Heroku is only allowing one server per slug. You may still run into problems on Heroku with the free redis instance. It is limited to 5mb. There is also pubnub instead of pusher, http://www.pubnub.com/price Pubnub has help documentation. There is also the option to run your app on EC2 free for a year on a micro instance (slow though)
Another cool but more work option is to use Torquebox (jruby app server). You would have to find different hosting, but it has inbuilt messaging.

Checking if the Faye server exists before running it for my Rails app

In relation to a previous question of mine found here:
Autorun the Faye server when I start the Rails server
I am now running the Faye server whenever I start Rails. However, this means it is trying to run the Faye server when I run the Rails server, the Rails console, or anything else Rails related.
Is there a way to check if the Faye server is already running? And if it is, not attempt to run a new one? Or maybe this isn't the best approach, I welcome all ideas and tips.
You can use the DaemonController library. It will enable you to auto-start services with your Rails app, starting them if they aren't already started.

Resources