# 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 = ProviderX.new(:user => 'foo', :password => 'secret')
# Let's see what ProviderX will allow us to deploy to
host.provides
> ['Amazon', 'Google']
# Let's create a new environment to deploy to
production = host.cloud.new(:vendor => 'Amazon', :name => 'production', :min_cpu => 2, :min_mem => 1024)
# We also would need to define the application that we wish to deploy
application = host.application.new(:repository => 'http://foo.com/foo.git', :type => 'Rails', :name => 'foo', :domain => 'foo.com', :ssl_enabled => true)
# All set! Let's deploy.
application.deploy_to production
application.deployed?
> true
application.deployed_to
> ['production']
production.applications
> ['foo']
# Maybe we forgot that we want to redirect www.foo.com to foo.com
application.redirects.add :from => 'www.foo.com', :to => 'foo.com'
# 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
end
# That's it for my day-dreaming.
Saturday, November 28, 2009
What If Hosting Was a Library?
Posted by
Justin Pease
at
9:37 AM
42
comments
Subscribe to:
Posts (Atom)