When Pow Eats Up the Clock Cycles

I have been a huge fan of Pow to serve my Rails applications for development on my Mac.  I wrote my love for Pow a while back and have been using it ever since, but all has not been a perfect experience along the way.  After upgrading to the 0.3.2 version I started to have my applications appear to lock up in the browser and finally timing out.

The only solution I could reliably make work was to open up Activity Monitor and kill the pow process manually.  It worked..until the next time and I would have to do it again and again.  It seemed like I was doing this many times a day.

It turned out this was a bug reported to the development team and is a confirmed issue.  The cause of the problem is determined to be the dns resolver, ndns.    A pre-release version, 0.4.0-pre is reported to resolve the issue.  Install it with the command:

curl get.pow.cx | VERSION=0.4.0-pre sh

I did this and have not had to manually restart pow once.  I’m not sure why the official release has not been updated to include the fix to this issue which seems to effect many users.


The Simplicity that is Pow

Logo pow

Simplicity is a beautiful thing.  I love a simple tool which makes my life as a developer easier.

Ruby on Rails has made the life of the web developer much more pleasurable over the years but even so there are some things which could be made better.  One such thing is running your Rails applications locally when developing.  Every Rails developer is familiar with the script/server command if you are in Rails 2.3 and earlier or the rails server command if you are using Rails 3.  The next step would be to fire up the browser and enter localhost:3000 into the address bar.  Most of the time this works fine, but a bit tedious.  The real problems appear when your application supports subdomains like myaccount.myapp.com, which has been hard to do up until this point.

Enter Pow

Pow is a Rack server developed by the folks at 37Signals to help alleviate the pain of serving local Rails applications.  Using Pow allows the developer to go from accessing their local Rails application using localhost:3000 to something like myrailsapp.dev.  For example, my expense tracking software, Expens’d uses subdomains quite a bit, so we get URLs like rbazinet.expensd.com and when using Pow I can simply use the URL rbazinet.expensd.dev.  This is perfect and simplifies the process.

Setting Up Pow for Serving Rails Applications

Installing Pow is pretty easy and shown on the Pow web site but for those not interested in heading over there you can open up a terminal session and enter the following:

$ curl get.pow.cx | sh

Each application has to have a symlink defined.  The Pow web site says to:

$ cd ~/.pow$ ln -s /path/to/my/app

When I setup Expens’d to use Pow setting up the symlink this way didn’t work for me.  I had to add the application name after the path, like this:

$ ln -s ~/rails_apps/expensd expensd

Since Expens’d is currently a Rails 2.3 application, a config.ru file is needed and placed in the application root folder.  The file should contain the following:

# RAILS_ROOT/config.ru
require "config/environment"
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new

If Expens’d was a Rails 3.x application, I would not have had to create the config.ru file.

Your mileage may vary.  Once the symlink is done heading to the browser you can just enter the domain for the application with the .dev extension, like expensd.dev.  This works just perfectly.

Restarting Your Application

One of the first things I wondered about when using Pow was a need to restart the “server” when I make changes to a routes.rb file.  It turns out we treat this the same way we restart Passenger.

$ [APP_ROOT]/touch tmp/restart.txt

Log File Monitoring

Using Pow provides us with the typical development.log file in the [APP_ROOT]/log directory.  Keeping an eye on the log can be done from a terminal window.

$ [APP_ROOT]/tail -f log/development.log

This provides  a nice way to see what’s going on.  There is also a raw log file produced from Pow that gives some additional details.

$ tail -f ~/Library/Logs/Pow/access.log

Potential Issue

When I setup Pow on my Mac Pro it all worked perfectly from the get-go but on my MacBook Pro I ran into a problem when I tried to browse a URL served by Pow such as expensd.dev.  DNS seemed to think I wanted to go to the Internet to find the site and I received a 404 error when I tried.    The problem was known and is outlined on Rob Conery’s site.  The first part of the solution involved running the scutil to see if .dev resolver was being used:

$ scutil --dns

You should see a bunch of entries and one should look something like this:

resolver #8
  domain : dev
  nameserver[0] :
  port    : 20560

I don’t know if Pow uses the same port all the time, so that may change.  The key here is the domain, indicating dev.  If this resolver is missing the solution is pretty simple, open the file /etc/resolver/dev and simply save it.  Worked like a charm for me.  Run the scutil –dns command from above and see if the resolver is now listed.

A Better Pow?

I think Pow is pretty awe some just as it is but it seems someone has stepped up to make it even better with a gem named Powder.  I haven’t had the chance to play around with this tool yet but a blog post by one of it’s creators says they wanted to make Pow “ridiculously easy”.  The commands supported help make Pow that much easier:

$ powder applog
=> tail the log of the current app
$ powder config
=> Get Pow's current configuration information
$ powder list
=> List all the current apps linked in ~/.pow
# aliased as powder -l
$ powder log
=> Tails the pow log.
# Not the application log, but the pow log, available at
# ~/Library/Logs/Pow/apps/#{app-directory}.log
$ powder open
=> Opens the pow link in a browser
# aliased as powder -o
$ powder open bacon
=> Opens http://bacon.dev in a browser
# if you have set up alternative top level domains in .powconfig,
# then the first listed domain will be opened.
$ powder restart
=> Restart the current app
# aliased as powder -r
$ powder status
=> Get Pow's current status information
$ powder version
=> Returns the current powder version
# aliased as powder -v

More Than Rails Applications

Since Pow is serves up Rack apps the possibilities are pretty endless.  I found one bit to share where someone is using Pow to serve his PHP apps, pretty clever.  I would imagine this technique could be used in many applications like this.


The only thing I can say is I love Pow.  It has made my life so much easier.  Thank you 37Signals.