watching a directory in ruby

后端 未结 6 1491
半阙折子戏
半阙折子戏 2020-12-14 01:04

We have an application that needs to process incoming files that are dropped into a directory. I am looking for the best way to do this.

We have been using a loopin

6条回答
  •  孤城傲影
    2020-12-14 02:00

    I think https://github.com/nex3/rb-inotify should work for you. An example to use this gem

    require 'rb-inotify'
    notifier = INotify::Notifier.new
    notifier.watch("/tmp", :moved_to, :create) do |event|
        puts "#{event.absolute_name} is now in path /tmp!"
    end
    notifier.run
    

提交回复
热议问题