Github said to come here for questions on the Listen gem as well as Guard, so ..
I have a workflow where my users submit PDFs from an iPad to a temporary directory on my server. I need my Rails app to watch that directory and move the files to their permanent location on the same machine. The Listen gem looks like the perfect solution, but I want to make sure this is the correct setup:
----
# config/initializers/listen.rb
callback = Proc.new do |modified, added, removed|
DocManager.new.move_all_to_destination
end
listener = Listen.to(Settings.fetch_directory).change(&callback)
listener.start(false)
----
This is working for test files, but is it running on the same thread as my Rails app? If I have to do a big file move, is that going to halt the app? Should I wrap it inside a Thread block, or are there other ways of handling this?
Thanks for any feedback!