Class: Tidings::Watcher
- Inherits:
-
Object
- Object
- Tidings::Watcher
- Defined in:
- lib/tidings/watcher.rb
Instance Method Summary collapse
-
#initialize(path, processor) ⇒ Watcher
constructor
A new instance of Watcher.
- #start ⇒ Object
- #stop ⇒ Object
- #watch ⇒ Object
Constructor Details
#initialize(path, processor) ⇒ Watcher
Returns a new instance of Watcher.
3 4 5 |
# File 'lib/tidings/watcher.rb', line 3 def initialize(path, processor) @path, @processor, @pid = path, processor, nil end |
Instance Method Details
#start ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/tidings/watcher.rb', line 7 def start Signal.trap("SIGINT") { stop } @pid = fork { watch } Tidings.log("Tidings running on PID: #{@pid}") Process.wait Tidings.log("Tidings stopped running") end |
#stop ⇒ Object
15 16 17 |
# File 'lib/tidings/watcher.rb', line 15 def stop Process.kill("KILL", @pid) end |