Class: Entangler::Executor::Base

Inherits:
Object
  • Object
show all
Includes:
Entangler::Executor::Background::Base, Processing::Base
Defined in:
lib/entangler/executor/base.rb

Direct Known Subclasses

Master, Slave

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, opts = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/entangler/executor/base.rb', line 14

def initialize(base_dir, opts = {})
  @base_dir = File.realpath(File.expand_path(base_dir))
  @notify_sleep = 0
  @exported_at = 0
  @opts = opts
  @opts[:ignore] = [/^\/\.git.*/] unless @opts.has_key?(:ignore)
  @opts[:ignore] << /^\/\.entangler.*/

  validate_opts
  logger.info("Starting executor")
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



12
13
14
# File 'lib/entangler/executor/base.rb', line 12

def base_dir
  @base_dir
end

Instance Method Details

#generate_abs_path(rel_path) ⇒ Object



26
27
28
# File 'lib/entangler/executor/base.rb', line 26

def generate_abs_path(rel_path)
  File.join(self.base_dir, rel_path)
end

#runObject



34
35
36
37
38
39
40
41
42
# File 'lib/entangler/executor/base.rb', line 34

def run
  start_notify_daemon
  start_local_io
  start_remote_io
  start_local_consumer
  logger.debug("NOTIFY PID: #{@notify_daemon_pid}")
  Signal.trap("INT") { kill_off_threads }
  wait_for_threads
end

#strip_base_path(path, base_dir = self.base_dir) ⇒ Object



30
31
32
# File 'lib/entangler/executor/base.rb', line 30

def strip_base_path(path, base_dir = self.base_dir)
  File.expand_path(path).sub(base_dir, '')
end