mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
vagrant detection attempt
This commit is contained in:
parent
7276542231
commit
2c4bd484af
1 changed files with 12 additions and 4 deletions
|
@ -37,7 +37,6 @@ class Autospec::Runner
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
|
|
||||||
if already_running?(pid_file)
|
if already_running?(pid_file)
|
||||||
puts "autospec appears to be running, it is possible the pid file is old"
|
puts "autospec appears to be running, it is possible the pid file is old"
|
||||||
puts "if you are sure it is not running, delete #{pid_file}"
|
puts "if you are sure it is not running, delete #{pid_file}"
|
||||||
|
@ -57,8 +56,15 @@ class Autospec::Runner
|
||||||
|
|
||||||
puts "Forced polling (slower) - inotify does not work on network filesystems, use local filesystem to avoid" if force_polling
|
puts "Forced polling (slower) - inotify does not work on network filesystems, use local filesystem to avoid" if force_polling
|
||||||
|
|
||||||
|
options = {filter: /^app|^spec|^lib/, relative_paths: true}
|
||||||
|
|
||||||
|
if force_polling
|
||||||
|
options[:force_polling] = force_polling
|
||||||
|
options[:latency] = 3
|
||||||
|
end
|
||||||
|
|
||||||
Thread.start do
|
Thread.start do
|
||||||
Listen.to('.', force_polling: force_polling, filter: /^app|^spec|^lib/, relative_paths: true) do |modified, added, removed|
|
Listen.to('.', options ) do |modified, added, removed|
|
||||||
process_change([modified, added].flatten.compact)
|
process_change([modified, added].flatten.compact)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -93,10 +99,11 @@ class Autospec::Runner
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'rb-inotify'
|
require 'rb-inotify'
|
||||||
|
require 'fileutils'
|
||||||
n = INotify::Notifier.new
|
n = INotify::Notifier.new
|
||||||
FileUtils.touch('./tmp/test_polling')
|
FileUtils.touch('./tmp/test_polling')
|
||||||
|
|
||||||
n.watch("./tmp", :delete){ works = true }
|
n.watch("./tmp", :modify, :attrib){ works = true }
|
||||||
quit = false
|
quit = false
|
||||||
Thread.new do
|
Thread.new do
|
||||||
while !works && !quit
|
while !works && !quit
|
||||||
|
@ -106,9 +113,10 @@ class Autospec::Runner
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sleep 0.01
|
sleep 0.01
|
||||||
File.unlink('./tmp/test_polling')
|
|
||||||
|
|
||||||
|
FileUtils.touch('./tmp/test_polling')
|
||||||
wait_for(100) { works }
|
wait_for(100) { works }
|
||||||
|
File.unlink('./tmp/test_polling')
|
||||||
n.stop
|
n.stop
|
||||||
quit = true
|
quit = true
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
|
|
Loading…
Reference in a new issue