From 22214f5e5c48a34640d899151ea39a9a50f1fe14 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 13 Apr 2017 10:26:07 -0400 Subject: [PATCH] Upgrade the Listen gem --- Gemfile | 2 +- Gemfile.lock | 8 ++++++-- lib/autospec/manager.rb | 4 +++- lib/stylesheet/watcher.rb | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 57e86b78176..0ae1f8ff4c1 100644 --- a/Gemfile +++ b/Gemfile @@ -122,7 +122,7 @@ end group :test, :development do gem 'rspec' gem 'mock_redis' - gem 'listen', '0.7.3', require: false + gem 'listen', require: false gem 'certified', require: false # later appears to break Fabricate(:topic, category: category) gem 'fabrication', '2.9.8', require: false diff --git a/Gemfile.lock b/Gemfile.lock index cdd13244cdd..a5a89ca661a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,7 +137,10 @@ GEM jwt (1.5.6) kgio (2.10.0) libv8 (5.3.332.38.5) - listen (0.7.3) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) logster (1.2.7) loofah (2.0.3) nokogiri (>= 1.5.9) @@ -312,6 +315,7 @@ GEM ruby-readability (0.7.0) guess_html_encoding (>= 0.0.4) nokogiri (>= 1.6.0) + ruby_dep (1.5.0) sanitize (4.4.0) crass (~> 1.0.2) nokogiri (>= 1.4.4) @@ -409,7 +413,7 @@ DEPENDENCIES htmlentities http_accept_language (~> 2.0.5) image_optim - listen (= 0.7.3) + listen logster lru_redux mail diff --git a/lib/autospec/manager.rb b/lib/autospec/manager.rb index 4833f22be31..450b2158552 100644 --- a/lib/autospec/manager.rb +++ b/lib/autospec/manager.rb @@ -179,12 +179,14 @@ class Autospec::Manager puts "@@@@@@@@@ Listen to #{path}/#{watch} #{options}" if @debug Thread.new do begin - Listen.to("#{path}/#{watch}", options) do |modified, added, _| + listener = Listen.to("#{path}/#{watch}", options) do |modified, added, _| paths = [modified, added].flatten paths.compact! paths.map!{|long| long[(path.length+1)..-1]} process_change(paths) end + listener.start + sleep rescue => e puts "FAILED to listen on changes to #{path}/#{watch}" puts e diff --git a/lib/stylesheet/watcher.rb b/lib/stylesheet/watcher.rb index 8f2005e74b7..c41e981c4c7 100644 --- a/lib/stylesheet/watcher.rb +++ b/lib/stylesheet/watcher.rb @@ -31,7 +31,7 @@ module Stylesheet @paths.each do |watch| Thread.new do begin - Listen.to("#{root}/#{watch}") do |modified, added, _| + listener = Listen.to("#{root}/#{watch}", ignore: /xxxx/) do |modified, added, _| paths = [modified, added].flatten paths.compact! paths.map!{|long| long[(root.length+1)..-1]} @@ -40,6 +40,8 @@ module Stylesheet rescue => e STDERR.puts "Failed to listen for CSS changes at: #{watch}\n#{e}" end + listener.start + sleep end end end