### Home Classes Methods

### In Files

- lib/phusion_passenger/standalone/app_finder.rb

### Parent

Object

### Methods

- ::looks_like_app_directory?
- ::new
- #monitor
- #scan

### Class/Module Index

Quicksearch

- PhusionPassenger
- PhusionPassenger::AbstractInstaller
- PhusionPassenger::AbstractInstaller::Abort
- PhusionPassenger::AbstractInstaller::CommandError
- PhusionPassenger::AdminTools
- PhusionPassenger::AdminTools::MemoryStats
- PhusionPassenger::AdminTools::MemoryStats::Process
- PhusionPassenger::AdminTools::ServerInstance
- PhusionPassenger::AdminTools::ServerInstance::CorruptedDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::GenerationsAbsentError
- PhusionPassenger::AdminTools::ServerInstance::Group
- PhusionPassenger::AdminTools::ServerInstance::Process
- PhusionPassenger::AdminTools::ServerInstance::RoleDeniedError
- PhusionPassenger::AdminTools::ServerInstance::StaleDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::Stats
- PhusionPassenger::AdminTools::ServerInstance::UnsupportedGenerationStructureVersionError
- PhusionPassenger::AnalyticsLogger
- PhusionPassenger::AnalyticsLogger::Connection
- PhusionPassenger::AnalyticsLogger::Lock
- PhusionPassenger::AnalyticsLogger::Log
- PhusionPassenger::ClassicRails
- PhusionPassenger::ClassicRails::CGIFixed
- PhusionPassenger::ClassicRails::ThreadHandlerExtension
- PhusionPassenger::ConsoleTextTemplate
- PhusionPassenger::DebugLogging
- PhusionPassenger::LoaderSharedHelpers
- PhusionPassenger::MessageChannel
- PhusionPassenger::MessageChannel::InvalidHashError
- PhusionPassenger::MessageClient
- PhusionPassenger::NativeSupportLoader
- PhusionPassenger::Packaging
- PhusionPassenger::PlatformInfo
- PhusionPassenger::PlatformInfo::ApacheDetector
- PhusionPassenger::PlatformInfo::ApacheDetector::Result
- PhusionPassenger::PlatformInfo::Depcheck
- PhusionPassenger::PlatformInfo::Depcheck::ConsoleRunner
- PhusionPassenger::PlatformInfo::Depcheck::Dependency
- PhusionPassenger::PlatformInfo::RuntimeError
- PhusionPassenger::Plugin
- PhusionPassenger::PreloaderSharedHelpers
- PhusionPassenger::Rack
- PhusionPassenger::Rack::OutOfBandGc
- PhusionPassenger::Rack::ThreadHandlerExtension
- PhusionPassenger::Rails3Extensions
- PhusionPassenger::Rails3Extensions::AnalyticsLogging
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ExceptionLogger
- PhusionPassenger::RequestHandler
- PhusionPassenger::RequestHandler::ThreadHandler
- PhusionPassenger::RequestHandler::ThreadHandler::Interrupted
- PhusionPassenger::SharedConstants
- PhusionPassenger::Standalone
- PhusionPassenger::Standalone::AppFinder
- PhusionPassenger::Standalone::Command
- PhusionPassenger::Standalone::ConfigFile
- PhusionPassenger::Standalone::ConfigFile::DisallowedContextError
- PhusionPassenger::Standalone::HelpCommand
- PhusionPassenger::Standalone::Main
- PhusionPassenger::Standalone::PackageRuntimeCommand
- PhusionPassenger::Standalone::RuntimeInstaller
- PhusionPassenger::Standalone::RuntimeLocator
- PhusionPassenger::Standalone::StartCommand
- PhusionPassenger::Standalone::StatusCommand
- PhusionPassenger::Standalone::StopCommand
- PhusionPassenger::Standalone::Utils
- PhusionPassenger::Standalone::VersionCommand
- PhusionPassenger::Utils
- PhusionPassenger::Utils::AnsiColors
- PhusionPassenger::Utils::FileSystemWatcher
- PhusionPassenger::Utils::FileSystemWatcher::DirInfo
- PhusionPassenger::Utils::FileSystemWatcher::FileInfo
- PhusionPassenger::Utils::GeneratorTest
- PhusionPassenger::Utils::HostsFileParser
- PhusionPassenger::Utils::JSON
- PhusionPassenger::Utils::JSON::Generator
- PhusionPassenger::Utils::ParserTest
- PhusionPassenger::Utils::TeeInput
- PhusionPassenger::Utils::TmpIO
- PhusionPassenger::Utils::UnseekableSocket
- CommonLibraryBuilder
- Exception
- GC
- IO
- Object
- Signal

No matching classes.

# PhusionPassenger::Standalone::AppFinder

Security note: can run arbitrary ruby code by evaluating passenger.conf

### Attributes

apps[R]
dirs[RW]

### Public Class Methods

looks_like_app_directory?(dir) click to toggle source

    # File lib/phusion_passenger/standalone/app_finder.rb, line 33
    def self.looks_like_app_directory?(dir)
            return File.exist?("#{dir}/config.ru") ||
                    File.exist?("#{dir}/config/environment.rb") ||
                    File.exist?("#{dir}/passenger_wsgi.py")
    end

new(dirs, options = {}) click to toggle source

    # File lib/phusion_passenger/standalone/app_finder.rb, line 39
    def initialize(dirs, options = {})
            @dirs = dirs
            @options = options
    end

### Public Instance Methods

monitor(termination_pipe) click to toggle source

    # File lib/phusion_passenger/standalone/app_finder.rb, line 77
    def monitor(termination_pipe)
            raise "You must call #scan first" if !@apps

            watcher = PhusionPassenger::Utils::FileSystemWatcher.new(@watchlist, termination_pipe)
            if wait_on_io(termination_pipe, 3)
                    return
            end

            while true
                    changed = watcher.wait_for_change
                    watcher.close
                    if changed
                            old_apps = @apps
                            # The change could be caused by a write to some passenger.conf file.
                            # Wait for a short period so that the write has a chance to finish.
                            if wait_on_io(termination_pipe, 0.25)
                                    return
                            end

                            new_apps = scan
                            watcher = PhusionPassenger::Utils::FileSystemWatcher.new(@watchlist, termination_pipe)
                            if old_apps != new_apps
                                    yield(new_apps)
                            end

                            # Don't process change events again for a short while,
                            # but do detect changes while waiting.
                            if wait_on_io(termination_pipe, 3)
                                    return
                            end
                    else
                            return
                    end
            end
    ensure
            watcher.close if watcher
    end

scan() click to toggle source

    # File lib/phusion_passenger/standalone/app_finder.rb, line 44
    def scan
            apps = []
            watchlist = []

            app_root = find_app_root
            apps << {
                    :server_names => ["_"],
                    :root => app_root
            }
            watchlist << app_root
            watchlist << "#{app_root}/config" if File.exist?("#{app_root}/config")
            watchlist << "#{app_root}/passenger.conf" if File.exist?("#{app_root}/passenger.conf")

            apps.sort! do |a, b|
                    a[:root] <=> b[:root]
            end
            apps.map! do |app|
                    config_filename = File.join(app[:root], "passenger.conf")
                    if File.exist?(config_filename)
                            local_options = load_config_file(:local_config, config_filename)
                            merged_options = @options.merge(app)
                            merged_options.merge!(local_options)
                            merged_options
                    else
                            @options.merge(app)
                    end
            end

            @apps = apps
            @watchlist = watchlist
            return apps
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.