Class: PhusionPassenger::Utils::FileSystemWatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/phusion_passenger/utils/file_system_watcher.rb

Defined Under Namespace

Classes: DirInfo, FileInfo

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filenames, termination_pipe = nil) ⇒ FileSystemWatcher

Returns a new instance of FileSystemWatcher.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/phusion_passenger/utils/file_system_watcher.rb', line 81

def initialize(filenames, termination_pipe = nil)
	@poll_interval = 3
	@termination_pipe = termination_pipe
	@dirs  = []
	@files = []

	begin
		filenames.each do |filename|
			stat = File.stat(filename)
			if stat.directory?
				@dirs << DirInfo.new(filename, stat)
			else
				@files << FileInfo.new(filename, stat)
			end
		end
	rescue Errno::EACCES, Errno::ENOENT
		@dirs = @files = nil
	end
end

Instance Attribute Details

#poll_intervalObject

Returns the value of attribute poll_interval.



75
76
77
# File 'lib/phusion_passenger/utils/file_system_watcher.rb', line 75

def poll_interval
  @poll_interval
end

Class Method Details

.opens_files?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/phusion_passenger/utils/file_system_watcher.rb', line 77

def self.opens_files?
	return false
end

Instance Method Details

#closeObject



115
116
# File 'lib/phusion_passenger/utils/file_system_watcher.rb', line 115

def close
end

#wait_for_changeObject



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/phusion_passenger/utils/file_system_watcher.rb', line 101

def wait_for_change
	if !@dirs
		return false
	end
	
	while true
		if changed?
			return true
		elsif select([@termination_pipe], nil, nil, @poll_interval)
			return nil
		end
	end
end