guard / listen

The Listen gem listens to file modifications and notifies you about the changes.
https://rubygems.org/gems/listen
MIT License
1.92k stars 246 forks source link

Rails with docker-compose, ignore folder doesn't work #456

Closed thierryfornetti closed 5 years ago

thierryfornetti commented 5 years ago

I'm running my rails application in a docker container, I'm using an after_initialize to start listening on a folder personal_files, but I don't want to listen to his subfolder called processed.

# /rails/config/initializers/guard_listen.rb

Rails.application.config.after_initialize do
  # Listen to file edits on personal_files folder

    listener = Listen.to("personal_files", force_polling: true, ignore: [%r{/personal_files/processed}]) do |modified, added, removed|
      puts "Listen\nmodified: #{modified.inspect}\nadded: #{added.inspect}\nremoved: #{removed.inspect}"
      ... process the images
    end
    listener.start

  end
end

I always receive a callback when a file is added or removed from the folder processed. I tried all the combinations I could think, even the full path (the full path inside the docker container) but nothing worked.

Any help? By the way, which is the correct way to ignore a subfolder?

thierryfornetti commented 5 years ago

After some hours, I found out the way to ignore a folder:

Listen.to("personal_files", force_polling: true, ignore: [%r{processed/}])