This is the first part of a series of blog posts that will show you how to setup your machine so that you can share sessions between Rails and Sinatra apps.
This idea was inspired by the In a World of Middleware, Who Needs Monolithic Applications? Mountain West Ruby Conference 2009 talk given by Corey Donohoe of Engine Yard.
However I will not be using Hancock or Hancock Client for Single Sign On. I think it is too complicated. I want something simple. My motivation is to build Rack compliant apps that are very focused on doing one thing really well and combining them to create a mashup.
At the end of the talk Corey said that in a world of why do we even need Rails? My opinion is that Rails app must be the last app in your Rack Stack and must be focused on your Core Domain. Anything else must be built as a Rack app. Because it is independent of your business and can be re-used across all your web apps.
Installation and Configuration
Environment: Ruby 1.8.7 managed by RVM
gem install passenger
Note: Steps 1 and 2 does not use sudo
sudo mkdir /usr/local/apache2/conf
Add the lines shown during installation to httpd.conf file and save it in the directory created above.
In my case it is:
LoadModule passenger_module /Users/bparanj/.rvm/gems/ruby-1.8.7-p299/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
4) Setup folder to hold vhosts
sudo mkdir /usr/local/apache2/conf/vhosts
5) Add the following to the httpd.conf
6) Add virtual hosts to a file virtual_hosts.conf under /usr/local/apache2/conf/vhosts directory
# Example App
# Example App 2
7) Edit /etc/hosts file
sudo vi /etc/hosts
127.0.0.1 app.test app2.test
sudo apachectl graceful or
sudo apachectl start
9) To restart app, create a file under RAILS_ROOT/tmp/restart.txt
when you run touch on restart.txt your Rails app will be reloaded