Adam Stacoviak

Divergence turns subdomains into remote branches

Switch branches as fast as you switch pages. Waiting for a deploy sucks. Allocating a staging server for each remote branch is costly. But nothing beats testing on a staging server with real production data. Divergence allows you to quickly test your remote branches simply by changing the subdomain.

If you’ve ever had the need for a second staging server for an early release of a feature that’s not ready to merge to master, Divergence from LayerVault could be what you’ve been waiting for.

Divergence sub-domain example

With Divergence you can easily view any branch from your repository on your staging server by using the branch name as the subdomain. Just use your branch name as the sub-domain and Divergence will magically find your branch and serve it up. You can even hook into a number of callbacks to automatically restart Passenger, run bundle install, or any other task if needed.

It’s a Rack application that acts as a HTTP proxy between you and your web application for rapid testing. Divergence was built with an Apache-Passenger stack in mind, so if you’re wanting to help develop the project further, checkout the contributing section of the readme.

Divergence is a work in progress, and labeled as a beta release. The folks at LayerVault could use a hand with:

  • Increased language support
  • More stacks supported, (e.g. nginx, Unicorn, etc.)
  • HTTPS support built-in

Sample config from the readme:

Divergence::Application.configure do |config|
  config.git_path = "/path/to/git_root"
  config.app_path = "/path/to/app_root"
  config.cache_path = "/path/to/cache_root"

  config.forward_host = 'localhost'
  config.forward_port = 80

  config.callbacks :after_swap do

  config.callbacks :after_cache, :after_webhook do
    bundle_install :path => "vendor/bundle"

  config.callbacks :on_branch_discover do |subdomain|
    case subdomain
    when "release-1"
    when "release-2"

Checkout the repo and readme for detailed instructions on installation and setup. If you’d like to see more stacks supported beyond an Apache-Passenger stack, fork it and help out.


Sign in or Join to comment or subscribe

0:00 / 0:00