77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# 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
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
if wait_on_io(termination_pipe, 3)
return
end
else
return
end
end
ensure
watcher.close if watcher
end
|