class EY::Serverside::Paths
Constants
- DEFAULT_MAINTENANCE_PAGE
This one is guaranteed to exist.
- MAINTENANCE_CANDIDATES
Maintenance
page candidates in order of search preference.
Attributes
deploy_root[R]
home[R]
Public Class Methods
def_path(name, parts)
click to toggle source
Define methods that get us paths
# File lib/engineyard-serverside/paths.rb, line 49 def self.def_path(name, parts) define_method(name.to_sym) { path(*parts) } end
new(opts)
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 98 def initialize(opts) @opts = opts @home = Pathname.new(@opts[:home] || ENV['HOME']) @app_name = @opts[:app_name] @active_release = Pathname.new(@opts[:active_release]) if @opts[:active_release] @repository_cache = Pathname.new(@opts[:repository_cache]) if @opts[:repository_cache] @deploy_root = Pathname.new(@opts[:deploy_root] || "/data/#{@app_name}") end
Public Instance Methods
active_release()
click to toggle source
If no active release is defined, use current
# File lib/engineyard-serverside/paths.rb, line 118 def active_release @active_release || latest_release end
all_releases()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 150 def all_releases @all_releases ||= Pathname.glob(path(:releases,'*')).sort end
deploy_hook(hook_name)
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 130 def deploy_hook(hook_name) path(:deploy_hooks, "#{hook_name}.rb") end
deploy_key()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 122 def deploy_key path(:home, '.ssh', "#{@app_name}-deploy-key") end
deployed?()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 174 def deployed? !!latest_release end
executable_deploy_hook(hook_name)
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 138 def executable_deploy_hook(hook_name) path(:deploy_hooks, "#{hook_name}") end
executable_service_hook(service_name, hook_name)
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 142 def executable_service_hook(service_name, hook_name) path(:shared_hooks, service_name, "#{hook_name}") end
latest_release()
click to toggle source
deploy_root/releases/<latest timestamp>
# File lib/engineyard-serverside/paths.rb, line 170 def latest_release all_releases.last end
maintenance_page_candidates()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 178 def maintenance_page_candidates if latest_release candidates = MAINTENANCE_CANDIDATES.map do |file| path(:latest_release, file) end else candidates = [] end candidates << DEFAULT_MAINTENANCE_PAGE candidates end
new_release!()
click to toggle source
if active_release
is already set, it’s set because we’re operating on an existing release. This happens during integrate
# File lib/engineyard-serverside/paths.rb, line 113 def new_release! @active_release ||= path(:releases, release_dirname) end
path(root, *parts)
click to toggle source
Load a path given a root and more parts Pathname#join is extremely inefficient. This implementation uses much less memory and way fewer objects.
# File lib/engineyard-serverside/paths.rb, line 56 def path(root, *parts) Pathname.new(File.join(send(root).to_s, *parts)) end
previous_release(from_release=latest_release)
click to toggle source
deploy_root/releases/<release before argument release path>
# File lib/engineyard-serverside/paths.rb, line 155 def previous_release(from_release=latest_release) index = all_releases.index(from_release) if index && index > 0 all_releases[index-1] else nil end end
previous_revision()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 164 def previous_revision rel = previous_release(active_release) rel && rel.join('REVISION') end
release_dirname()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 107 def release_dirname Time.now.utc.strftime("%Y%m%d%H%M%S") end
repository_cache()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 146 def repository_cache @repository_cache ||= default_repository_cache end
rollback()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 190 def rollback if deployed? && previous_release self.class.new(@opts.dup.merge(:active_release => previous_release)) else nil end end
service_hook(service_name, hook_name)
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 134 def service_hook(service_name, hook_name) path(:shared_hooks, service_name, "#{hook_name}.rb") end
ssh_wrapper()
click to toggle source
# File lib/engineyard-serverside/paths.rb, line 126 def ssh_wrapper path(:shared_config, "#{@app_name}-ssh-wrapper") end