class Inquirer::Daemon

Overview

The Inquirer daemon listens for certain changes in watchables (watchable directories), which are recursively looked up from the root (origin) directory, and reports those changes to the Inquirer server.

Included Modules

Defined in:

inquirer/daemon.cr

Constant Summary

MAX_WATCHES = (File.read("/proc/sys/fs/inotify/max_user_watches")).to_i

Maximum amount of watches that this system allows.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(config : Config) #

Makes an Inquirer daemon from the given config.


[View source]

Class Method Detail

def self.start(config : Config) #

Initializes a daemon and starts it.

See initialize, #start.


[View source]

Instance Method Detail

def handle(server : Inquirer::Server, event : Inotify::Event) #

Handles a change in a watchable.

  • If a Ven file ('[^_]*.ven') was created, modified, deleted or moved (inotify MODIFY, CREATE, DELETE and MOVE, correspondingly), the appropriate command about that change is sent to the server.
  • If a watchable directory was created, a watcher is set on this directory.
  • If a watchable directory was removed, its watcher is (automatically) suspended.

Returns nothing.


[View source]
def register_existing_files(server : Inquirer::Server) #

Registers Ven files that are already in watchables.

Any file that ends with '.ven' and is not prefixed with an underscore is considered a Ven file.

Requires watchables to be looked up beforehand.

May take a long time as well.


[View source]
def start #

Starts this daemon. Detaches (daemonizes) if the config says to.

Does not check whether another daemon is running on the same port.

Returns nothing.


[View source]
def stop #

Gracefully stops this daemon.


[View source]
def watchable?(path : String) : Bool #

Returns whether the directory at path is watchable.

Directories that are not watchable:

  • Those whose name is prefixed with an underscore;
  • Those that are ignored through the config;
  • Those that are symlinks;
  • Those that are hidden.

[View source]
def watchables : Array(String) #

Returns the directories that this daemon watches.


[View source]
def watchables! #

Fills up this daemon's list of watchable (see #watchable?) directories.

Depth (amount of nesting) is unlimited. Searches through everything under the origin directory, so may take a long time.


[View source]