Permalink
Browse files

fixed runner loads file multi-times problem

  • Loading branch information...
1 parent 33d0372 commit 3e80c07c5144522f7c13ce0ea75661ca1ed2db39 Li Xiao committed Nov 7, 2008
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/dtr/agent/working_env_ext.rb
@@ -31,8 +31,8 @@ def load_environment(&block)
setup_environment
- load_libs
- load_files
+ append_libs_to_load_path
+ require_files
block.call
end
@@ -54,20 +54,21 @@ def escape_dir(str)
str.to_s.gsub(/[^a-zA-Z0-9]/, '_')
end
- def load_libs
+ def append_libs_to_load_path
libs.select{ |lib| !$LOAD_PATH.include?(lib) && File.exists?(lib) }.each do |lib|
$LOAD_PATH << lib
DTR.debug {"appended lib: #{lib}"}
end
- DTR.info {"libs loaded"}
+ DTR.info {"libs appended"}
DTR.debug {"$LOAD_PATH: #{$LOAD_PATH.inspect}"}
end
- def load_files
+ def require_files
files.each do |f|
begin
- load f unless f =~ /^-/
- DTR.debug {"loaded #{f}"}
+ #use require instead of load to avoid load file twice.
+ require f unless f =~ /^-/
+ DTR.debug {"required #{f}"}
rescue LoadError => e
DTR.error {"No such file to load -- #{f}"}
DTR.debug {"Environment: #{self}"}

0 comments on commit 3e80c07

Please sign in to comment.