Class: S5::Daemon
- Inherits:
-
Object
- Object
- S5::Daemon
- Defined in:
- lib/s5/daemon.rb
Instance Attribute Summary collapse
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(*paths, bucket_name: nil) ⇒ Daemon
constructor
A new instance of Daemon.
- #observe ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
4 5 6 |
# File 'lib/s5/daemon.rb', line 4 def pid @pid end |
Instance Method Details
#observe ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/s5/daemon.rb', line 23 def observe observers = @syncs.map!{|path, sync| sync.sync! [path, create_or_update(sync), delete(sync)] } FSSM.monitor do observers.each do |_, create_or_update, delete_proc| path _ do glob '**/*' create &create_or_update update &create_or_update delete &delete_proc end end end end |
#start ⇒ Object
13 14 15 16 17 |
# File 'lib/s5/daemon.rb', line 13 def start @pid = fork do observe end end |
#stop ⇒ Object
19 20 21 |
# File 'lib/s5/daemon.rb', line 19 def stop Process.kill :QUIT, @pid end |