Skip to content

Instantly share code, notes, and snippets.

@e2
Last active July 11, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save e2/11251178 to your computer and use it in GitHub Desktop.
Save e2/11251178 to your computer and use it in GitHub Desktop.
Script for testing inotify and listen on Linux
gem "rb-inotify"
require 'rb-inotify'
gem "listen"
require "listen"
dir = '.'
Listen.to(dir) do |modified, added, removed|
puts "listen: #{[added, modified, removed].inspect}!"
end.start
events = [:recursive, :attrib, :create, :delete, :move, :close_write]
INotify::Notifier.new.tap do |notifier|
notifier.watch(dir, *events) do |event|
puts "rb-inotify event: #{event.name} #{event.flags.inspect}"
end
notifier.run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment