Faye (github) is a rack-based messaging system that allows web clients to communicate.
Heroku can be restrictive given memory and processor constraints, especially at the free level, so running any Faye server concurrently with a rails app isn't stable.
This project makes it easy by giving you a barebones private_pub that runs as a separate app on Heroku.
Setting up heroku_private_pub is pretty easy, just clone, edit one file, and push to Heroku. Of course, there's a little handwaving for you, so here are the excruciating details.
Clone heroku_private_pub to your development computer, in a new project folder (not the same as your rails project). In this example we'll call it 'mypubserver':
~> cd projects ~/projects> git clone git://github.com/IamNaN/heroku_private_pub mypubserver Cloning into 'mypubserver'... remote: Counting objects: 15, done. remote: Compressing objects: 100% (11/11), done. remote: Total 15 (delta 3), reused 14 (delta 2) Receiving objects: 100% (15/15), done. Resolving deltas: 100% (3/3), done. ~/projects> cd mypubserver ~/projects/mypubserver>
config/private_pub.yamland replace MY_KEY with the same one you have in the
private_pub.ymlof your rails project. Also, replace MY_APP with the name of the heroku app where this private_pub server will be install (this is different from the name of your rails app). Save this file.
- Run the bundler to install the gems
~/projects/mypubserver> bundle install
- Commit the changes locally.
~/projects/mypubserver> git commit -am "Adding my configuration info"
- Install the heroku gem if you haven't already. They are "sunsetting" (a nice way of saying leaving you in the dark) the heroku gem soon in favor of a less-rails-y toolbelt. I'll abandon heroku when they abandon the gem, so maybe someone else will contribute that update.
~/projects/mypubserver> gem install heroku
- Create your heroku app with the heroku tool installed by the gem.
~/projects/mypubserver> heroku apps:create mypubserver Creating mypubserver... done, stack is cedar http://mypubserver.herokuapp.com/ | firstname.lastname@example.org:mypubserver.git Git remote heroku added
- Push it to heroku.
~/projects/mypubserver> git push heroku master
After you have verified everything is working as expected (see Troubleshooting below) you can delete this project. However, it is handy if you ever want to watch the traffic going through your Faye server (see "What's It Saying?" below).
If it is unlikely you'll ever need it again. In the even that you find yourself needing it again, you can just pull it from Heroku thusly:
git clone email@example.com:mypubserver.git mypubserver
Make your changes, commit them, and push them again just like we did above.
You can test that your new Faye server running properly by browsing to the app. In the above example, we would go to http://mypubserver.herokuapp.com should see a plain text message "Sure you're not looking for /faye?"
If that is working but your messages aren't finding their way between your app and clients, double check the settings in
config\private_pub.yml match those in the same file in your rails project.
If that's correct but you're still seeing problems, then check out the log to see what the problem is.
~/projects/mypubserver> heroku logs --tail