    # File lib/phusion_passenger/admin_tools/server_instance.rb, line 140
            def initialize(path)
                    raise ArgumentError, "Path may not be nil." if path.nil?
                    @path = path

                    if File.exist?("#{path}/control_process.pid")
                            data = File.read("#{path}/control_process.pid").strip
                            @pid = data.to_i
                    else
                            path =~ /passenger\.\d+\.\d+\.(\d+)\Z/
                            @pid = $1.to_i
                    end

                    generations = Dir["#{path}/generation-*"]
                    if generations.empty?
                            raise GenerationsAbsentError, "There are no generation subdirectories in this instance directory."
                    end
                    highest_generation_number = 0
                    generations.each do |generation|
                            File.basename(generation) =~ /(\d+)/
                            generation_number = $1.to_i
                            if generation_number > highest_generation_number
                                    highest_generation_number = generation_number
                            end
                    end
                    @generation_path = "#{path}/generation-#{highest_generation_number}"

                    if !File.exist?("#{@generation_path}/structure_version.txt")
                            raise CorruptedDirectoryError, "The generation directory doesn't contain a structure version specification file."
                    end
                    version_data = File.read("#{@generation_path}/structure_version.txt").strip
                    major, minor = version_data.split(".", 2)
                    if major.nil? || minor.nil? || major !~ /\A\d+\Z/ || minor !~ /\A\d+\Z/
                            raise CorruptedDirectoryError, "The generation directory doesn't contain a valid structure version specification file."
                    end
                    major = major.to_i
                    minor = minor.to_i
                    if major != GENERATION_STRUCTURE_MAJOR_VERSION || minor > GENERATION_STRUCTURE_MINOR_VERSION
                            raise UnsupportedGenerationStructureVersionError, "Unsupported generation directory structure version."
                    end

                    if @pid == 0
                            raise CorruptedDirectoryError, "Instance directory contains corrupted control_process.pid file."
                    elsif !AdminTools.process_is_alive?(@pid)
                            raise StaleDirectoryError, "There is no instance with PID #{@pid}."
                    end
            end