Saturday, November 28, 2009

What If Hosting Was a Library?

# Was thinking, "if hosting was a library, what might it look like..."

require 'ProviderX'

# We'll pretend we already have an account with fictitious ProviderX

host = => 'foo', :password => 'secret')

# Let's see what ProviderX will allow us to deploy to

> ['Amazon', 'Google']

# Let's create a new environment to deploy to

production = => 'Amazon', :name => 'production', :min_cpu => 2, :min_mem => 1024)

# We also would need to define the application that we wish to deploy

application = => '', :type => 'Rails', :name => 'foo', :domain => '', :ssl_enabled => true)

# All set! Let's deploy.

application.deploy_to production

> true

> ['production']

> ['foo']

# Maybe we forgot that we want to redirect to

application.redirects.add :from => '', :to => ''

# We don't want to deploy the code again, we just want to sync configuration changes (the redirect).

application.sync_configs production

# Perhaps we could control our resources from within our application

if production.swapping?
  production.ram.add 128

# That's it for my day-dreaming.

1 comment:

  1. The vendors should just conform to the host interface. Less typing, more explicit.

    production = blah)

    Honestly, I've learned to live without stuff like Capistrano though and realized my life is simpler for it. Shell scripts FTW. :-)