- Timestamp:
- Jan 8, 2010, 2:15:22 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/locker-dev/locker/deploy/bin/rails
r1408 r1410 130 130 131 131 t2 = Thread.new do 132 # List of directories to watch for changes before reload133 132 Thread.current[:watched_dirs] = ['app', 'config', 'db', 'lib', 'public'] 134 # Sample filter: /(\.rb|\.erb)\$/. Default filter: watch all files135 133 Thread.current[:watched_extensions] = // 134 # Iterations since last reload 135 Thread.current[:iterations] = 0 136 136 137 137 def modified(file) 138 mtime = File.stat(file).mtime 139 Thread.current[:modifications][file] ||= mtime 140 Thread.current[:modifications][file] != mtime 138 begin 139 mtime = File.stat(file).mtime 140 rescue 141 false 142 else 143 if Thread.current[:iterations] == 0 144 Thread.current[:modifications][file] = mtime 145 end 146 Thread.current[:modifications][file] != mtime 147 end 141 148 end 142 149 143 # Don't symlink yourself into a loop. Please. 150 # Don't symlink yourself into a loop. Please. Things will still work 151 # (Linux limits your symlink depth) but you will be sad 144 152 def modified_dir(dir) 145 153 Dir.new(dir).each do |file| … … 150 158 else 151 159 return true if Thread.current[:watched_extensions] =~ absfile && 152 160 modified(absfile) 153 161 end 154 162 end … … 158 166 def reload 159 167 Thread.current[:modifications] = {} 168 Thread.current[:iterations] = 0 160 169 RailsFCGIHandler.reload! 161 170 end … … 164 173 # Wait until the modify time changes, then reload. 165 174 while true 166 reload if Thread.current[:watched_dirs].inject(false) {|z, dir| z || 167 modified_dir(File.join(File.dirname(__FILE__), '..', dir))}175 reload if Thread.current[:watched_dirs].inject(false) {|z, dir| z || modified_dir(File.join(File.dirname(__FILE__), '..', dir))} 176 Thread.current[:iterations] += 1 168 177 sleep 1 169 178 end
Note: See TracChangeset
for help on using the changeset viewer.