(Ka)Pow

If you do any Rack or Ruby on Rails development, you should checkout Pow, the zero configuration Rack server for OS X.

Pow makes getting up and running with these apps dead simple. No running

1
rails server
one app at a time, no Apache/Passenger configs to setup, no mucking with
1
/etc/hosts
. Pow doesn’t require special privileges (runs as your user), with no gems or extensions to intall. Just Pow, and it installs in seconds.

From the manual:

How does it work? A few simple conventions eliminate the need for tedious configuration. Pow runs as your user on an unprivileged port, and includes both an HTTP and a DNS server. The installation process sets up a firewall rule to forward incoming requests on port 80 to Pow. It also sets up a system hook so that all DNS queries for a special top-level domain (.dev) resolve to your local machine.

###The good and bad: ###

  • Any request to *.dev is sent to Pow
  • Pow by default hijacks port 80

You can configure that last one, and it’s simple to do so, incase you do any other type of development where you already have something like Apache setup to handle those requests. Without configuring otherwise Pow will respond instead and likely not know what to do.

###Setup and adding Apps###

Installation requires authentication simply because it creates a new Firewall rule.

$ curl get.pow.cx | sh
*** Installing Pow 0.3.1...
*** Installing local configuration files...
*** Starting the Pow server...
*** Performing self-test...
*** Installed

It’s that easy. Uninstallation is just as easy too:

$ curl get.pow.cx/uninstall.sh | sh
Sorry to see you go. Uninstall Pow [y/n]? y
*** Uninstalling Pow...
*** Uninstalled

Pow creates a

1
~/.pow
directory in your home folder. To setup an app with Pow,
1
cd
there and create a symlink:

$ cd ~/.pow
$ ln -s /some/rackapp

Done! Visit

1
http://rackapp.dev
and you’re rack app will load before your awe-struck eyes.

###But what about my port 80?###

Yeah, you probably want that back huh… Fortunately you have some options there, detailed on this helpful wiki on the Pow Github project. It outlines two steps, but depending on your desired setup, you may be fine with just the first one.

####Without adjusting Apache####

Create a

1
~/.powconfig
file and put the following there:

# ~/.powconfig
export POW_DST_PORT=88

On Boot, Pow will read that file for any configuration options (more here). This tells Pow not to use port 80, but instead use port 88.

From there forward, just add

1
:88
to your app urls, a la
1
http://rackapp.dev:88
. Apache will still use port 80 and your other apps will be fine, while any Pow app now responds to
1
<app-name>.dev:88
.

####Adjusting Apache####

If you like the idea of not having to specify a port at all, you can do the additional step of adding an Apache conf file in

1
/etc/apache2/other/
instructing Apache to act as a reverse proxy for Pow instead. This allows you to have your Pow apps respond at
1
<app-name>.dev
, while maintaining your current Apache process.

$ sudo curl https://raw.github.com/gist/1058580/zzz_pow.conf -o /etc/apache2/other/zzz_pow.conf
$ sudo apachectl restart

The naming is important because Apache will load it last. You want Apache to behave like normal for all requests and then proxy anything that doesn’t match your other host files to the Pow server.

###A little Pow(der)###

Pow has already made your life better, what more could you want?

You’re right,

1
cd ~/.pow
and creating a symlink is asking an awful lot of you just to run multiple Rack apps simultaneously with no hassle…

So you use Powder, a handy little gem that lets you link and unlink Pow apps without leaving the comfort of your

1
cwd
. And hey, it can give you a bit more insight to what Pow’s doing too.

$ powder help
Tasks:
  powder applog       # Tails in current app
  powder config       # Shows current pow configuration
  powder down         # Disable pow
  powder help [TASK]  # Describe available tasks or one specific task
  powder install      # Installs pow
  powder link         # Link a pow
  powder list         # List current pows
  powder log          # Tails the Pow log
  powder open         # Open a pow in the browser
  powder remove       # An alias to Unlink (depreciated)
  powder restart      # Restart current pow
  powder status       # Shows current pow status
  powder uninstall    # Uninstalls pow
  powder unlink       # Unlink a pow app
  powder up           # Enable pow
  powder version      # Shows the version

###Epilogue###

Pow gives you really, really easy setups for your Rack apps. Now you can work on several at the same time or support interaction between them with ease. Coupled with one-line install/uninstall, the barrier to entry is incredibly low too, so give it a shot. It can make your (dev) life simpler.

@ctshryock

About

My name is Clint Shryock. I develop things in Go and Ruby. I live in central Missouri, where the weather is beautiful 4 months of the year.
+-----------------+
|                       |
|      (ノ^_^)ノ      |
|                       |
|   ☜(゚ヮ゚☜)    |
|                       |
|     ౿(ఠ_ఠఎ)    |
|                       |
|        ಠ_ಠ         |
x                      x
  xxx           xxx
       xx    xx
           xx