def list(options = {})
options = {
:clean_stale_or_corrupted => true
}.merge(options)
instances = []
@paths.each do |path|
Dir["#{path}/passenger.*"].each do |dir|
instance = Instance.new(dir)
case instance.state
when :good
if instance.locked?
instances << instance
elsif options[:clean_stale_or_corrupted]
cleanup(dir)
end
when :structure_version_unsupported
next
when :corrupted
if !instance.locked? && options[:clean_stale_or_corrupted]
cleanup(dir)
end
when :not_finalized
if instance.stale? && options[:clean_stale_or_corrupted]
cleanup(dir)
end
end
end
end
instances
end