I wanted to do a quick write up of how I use Pow to run several rails/rack apps and provide subdomains for the rails / rack apps as well as node.js servers! I’ll even throw in a Livereload plug in Rails/rack.
We have several rails projects – an API server, a queue’ing rails project running Sidekiq, an admin dashboard using Rails & angular, and a node.js server running a PhoneGap mobile app run in express.
I needed an easy domain set up, something like:
I also needed Livereload due to the time it saves, who doesn’t right? I do ok, quit asking questions. (But seriously please comment and ask)
What I did
After installing POW, I created a few symbolic links and a file containing the port that I would run the node.js server. As seen in the the POW documentation and listed in the same order as above.
1 2 3 4 5 6
Awesome. So now Pow got the rails/racks apps up. Just need to start my node server by simply running
Ensure its there
Now that I’ve got the servers all running, i’ll hit them up to check A-OK. Navigate to
http://project.dev. Yep, all A-OK.
Now to set up Livereload.
Snag up a few gems to help Rails/rack do some livereloads automatically for me.
1 2 3
Two things to configure before livereload will work in the rails/rack apps – the first is a config setting in our development.rb file and our Guardfile with a host definition.
The first is development.rb:
1 2 3 4 5
Now the magic for the rails/rack apps is the Guardfile:
1 2 3 4 5 6 7 8
Boom! Now I’ve got Livereload being injected into each of the rails/rack apps I configured and handling all the other business. I just have to sit back and code.
Hope this helps any who may be wanting a similar set up with subdomains with rails/rack & node.js hosted apps.