Class: Watchcat::Executor
- Inherits:
-
Object
- Object
- Watchcat::Executor
- Defined in:
- lib/watchcat/executor.rb
Instance Method Summary collapse
-
#initialize(paths, recursive:, force_polling:, poll_interval:, wait_until_startup:, ignore_remove:, debounce:, block:) ⇒ Executor
constructor
A new instance of Executor.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(paths, recursive:, force_polling:, poll_interval:, wait_until_startup:, ignore_remove:, debounce:, block:) ⇒ Executor
Returns a new instance of Executor.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/watchcat/executor.rb', line 8 def initialize(paths, recursive:, force_polling:, poll_interval:, wait_until_startup:, ignore_remove:, debounce:, block:) @service = nil @child_pid = nil @paths = paths @recursive = recursive @force_polling = force_polling @poll_interval = poll_interval @wait_until_startup = wait_until_startup @ignore_remove = ignore_remove @debounce = debounce @block = block @watcher = Watchcat::Watcher.new end |
Instance Method Details
#start ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/watchcat/executor.rb', line 22 def start server = Server.new(@block) @service = DRb.start_service("drbunix:", server) client = nil client = build_client if @wait_until_startup @child_pid = fork do client = build_client unless @wait_until_startup Process.setproctitle("watchcat: watcher") client.run end main = Process.pid at_exit do @exit_status = $!.status if $!.is_a?(SystemExit) stop if Process.pid == main exit @exit_status if @exit_status end end |
#stop ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/watchcat/executor.rb', line 42 def stop begin @watcher.close Process.kill(:KILL, @child_pid) rescue Errno::ESRCH # NOTE: We can ignore this error because there process is already dead. end @service.stop_service end |