Skip to content

Commit

Permalink
fixing high cpu usage for polling
Browse files Browse the repository at this point in the history
  • Loading branch information
teknofire authored and Processing committed May 10, 2012
1 parent 7840abc commit 41d38e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/conveyor/foreman.rb
Expand Up @@ -56,7 +56,15 @@ def watch(*args, &block)
raise "Directory #{dir} not found" unless File.directory? dir

listener = Listen.to(dir)
listener.latency(0.5)

if opts[:latency]
listener.latency(opts[:latency])
elsif opts[:force_polling]
listener.latency(5)
else
listener.latency(0.5)
end

listener.ignore(opts[:ignore]) if opts[:ignore]
listener.force_polling(opts[:force_polling]) if opts[:force_polling]

Expand Down
3 changes: 2 additions & 1 deletion lib/conveyor/worker.rb
Expand Up @@ -35,8 +35,9 @@ def watch(*args, &block)
end

def match(glob, &block)
debug "#{@filename} matches? #{glob}"
# puts File.fnmatch(glob, @filename)
if File.fnmatch(glob, @filename)
if File.fnmatch(glob, @filename, File::FNM_PATHNAME | File::FNM_DOTMATCH)
yield @filename
end
end
Expand Down

0 comments on commit 41d38e8

Please sign in to comment.