class Evesync::Watcher

Watcher class responds for starting all watchers (e.g. package and file). Watchers are initialized in their own threads. Watcher::Main supports start/stop methods or starting and stopping watchers.

Example:

w = Evesync::Watcher.new
w.start # so, all needful watchers are started

TODO:

* Add ability to restart watchers if something happend

Constants

Package

Watcher for package changes for Arch Linux

Example

Thread.new { IPC::Data::PackageWatcher.new(queue).run }


WATCHER_CLASSES

Public Class Methods

new(queue) click to toggle source
# File lib/evesync/watcher.rb, line 28
def initialize(queue)
  # Creating subwatchers
  Log.debug('Watcher initialization started...')
  @queue = queue
  @watchers = []
  WATCHER_CLASSES.each do |w_class|
    @watchers << w_class.new(@queue)
  end
  Log.debug('Watcher initialization done!')
end

Public Instance Methods

start() click to toggle source

Starts watchers threads

Returns

self

# File lib/evesync/watcher.rb, line 42
def start
  @threads ||= []
  if @threads.empty?
    @watchers.each do |watcher|
      @threads << watcher.start
    end
  end

  Log.debug('Watcher thread started')
  self
end
stop() click to toggle source

Stops all watcher threads

Returns

self

# File lib/evesync/watcher.rb, line 57
def stop
  @watchers.each do |watcher|
    @threads << watcher.stop
  end
  @threads.each(&:exit)

  Log.debug('Watcher threads stopped')
  self
end