From: Brian Candler Date: 2005-06-25T18:28:43+09:00 Subject: Re: FastCGI: handling the caching of ruby scripts. On Fri, Jun 24, 2005 at 10:25:06PM +0900, Jonas Hartmann wrote: > I cannot make the last example on this Page: > http://rubygarden.org/ruby/ruby?FCGIRubyWhyArentMyChangesDisplayed > working yet... Which one - the "FastCgiConfig -autoUpdate" or the Thread.new ? Both will only work if the main application file itself has updated, not any libraries which it 'requires' You could write something which checks all the files in $". However, those paths are not absolute, and each one would have to be searched against $: to find them. Hmm, I don't see a Ruby function to search for a file in a path (strange, maybe I'm missing something), so this gets a bit more long-winded than I expected: ---- 8< ----------------------------------------------------------------- #!/usr/bin/env ruby require 'fcgi' # ... more requires def path_search(file, pathlist) return file if file[0..0] == File::SEPARATOR and File.exist?(file) pathlist.each do |p| fn = p+File::SEPARATOR+file return fn if File.exist?(fn) end nil end Thread.new([File.expand_path(__FILE__)]) do |fname| old_stats = {} while true (fname+$").each do |f| stat = File.stat(path_search(f,$:)) rescue nil if stat and old_stats[f] exit if stat.mtime != old_stats[f].mtime or stat.ino != old_stats[f].ino end old_stats[f] = stat end sleep 10 end end #... rest if program ---- 8< ----------------------------------------------------------------- To debug this, set "Thread.abort_on_exception=true" at the top. I think this should work even if the number of files 'required' by the program increases over time. Regards, Brian.