Class: Inari::TaskProcess
- Inherits:
-
Daemon::Base
- Object
- Daemon::Base
- Inari::TaskProcess
- Defined in:
- lib/inari/task_process.rb
Overview
Starts a process that runs a task.
Class Method Summary collapse
Methods inherited from Daemon::Base
Class Method Details
.daemonize(taskmanager, task) ⇒ Object
39 40 41 42 |
# File 'lib/inari/task_process.rb', line 39 def self.daemonize(taskmanager, task) @@taskmanager, @@task = taskmanager, task Daemon::Controller.daemonize(self) end |
.start ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/inari/task_process.rb', line 7 def self.start Inari::logger.info "Monitoring started for task #{@@task[0]}" semaphore = Mutex.new # Run threads for each host threads = [] @@task[1].hosts.each do |host| threads << Thread.new do loop do semaphore.synchronize do begin @@taskmanager.commands.host = host @@taskmanager.send(@@task[0]) rescue Timeout::Error # Potential network timeout issue @@taskmanager.commands.down end end sleep @@taskmanager.commands.sleep end end end threads.each do |thread| thread.join end rescue ArgumentError Daemon::Controller.remove_pid_file(self) raise end |
.stop ⇒ Object
44 |
# File 'lib/inari/task_process.rb', line 44 def self.stop ; end |