Parent

Class/Module Index [+]

Quicksearch

PhusionPassenger::Standalone::AppFinder

Attributes

apps[R]
dirs[RW]
execution_root[R]

Public Class Methods

looks_like_app_directory?(dir, options = {}) click to toggle source
# File lib/phusion_passenger/standalone/app_finder.rb, line 46
def self.looks_like_app_directory?(dir, options = {})
  options = options.dup
  ConfigUtils.load_local_config_file!(dir, options)
  return options[:app_type] ||
    STARTUP_FILES.any? do |file|
      File.exist?("#{dir}/#{file}")
    end
end
new(dirs, options = {}) click to toggle source
# File lib/phusion_passenger/standalone/app_finder.rb, line 59
def initialize(dirs, options = {})
  @dirs = dirs
  @options = options.dup
  determine_mode_and_execution_root(options)
end
supports_multi?() click to toggle source
# File lib/phusion_passenger/standalone/app_finder.rb, line 55
def self.supports_multi?
  false
end

Public Instance Methods

monitor(termination_pipe) click to toggle source
# File lib/phusion_passenger/standalone/app_finder.rb, line 92
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 Passengerfile.json 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
multi_mode?() click to toggle source
# File lib/phusion_passenger/standalone/app_finder.rb, line 134
def multi_mode?
  return !single_mode?
end
scan() click to toggle source
# File lib/phusion_passenger/standalone/app_finder.rb, line 65
def scan
  apps = []
  watchlist = []

  if single_mode?
    app_root = find_app_root
    apps << {
      :server_names => ["_"],
      :root => app_root
    }
    watchlist << app_root
    WATCH_ENTRIES.each do |entry|
      if File.exist?("#{app_root}/#{entry}")
        watchlist << "#{app_root}/#{entry}"
      end
    end

    apps.map! do |app|
      @options.merge(app)
    end
  end

  @apps = apps
  @watchlist = watchlist
  return apps
end
single_mode?() click to toggle source
# File lib/phusion_passenger/standalone/app_finder.rb, line 130
def single_mode?
  return @mode == :single
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.