Class: Slugrunner::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/slugrunner/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slug, process_type, instance_number) ⇒ Runner



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/slugrunner/runner.rb', line 18

def initialize(slug, process_type, instance_number)
  @slug = slug
  @process_type = process_type
  @ping = false
  @bind_delay = 0
  @ping_url = nil
  @ping_interval = 0
  @alive = false
  @shell = false
  @extra_env = []
  @hostname = "#{@process_type}.#{instance_number}"
end

Instance Attribute Details

#bind_delayObject

Returns the value of attribute bind_delay.



12
13
14
# File 'lib/slugrunner/runner.rb', line 12

def bind_delay
  @bind_delay
end

#extra_envObject

Returns the value of attribute extra_env.



16
17
18
# File 'lib/slugrunner/runner.rb', line 16

def extra_env
  @extra_env
end

#ping_intervalObject

Returns the value of attribute ping_interval.



14
15
16
# File 'lib/slugrunner/runner.rb', line 14

def ping_interval
  @ping_interval
end

#ping_urlObject

Returns the value of attribute ping_url.



13
14
15
# File 'lib/slugrunner/runner.rb', line 13

def ping_url
  @ping_url
end

#shellObject

Returns the value of attribute shell.



15
16
17
# File 'lib/slugrunner/runner.rb', line 15

def shell
  @shell
end

Instance Method Details

#runObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/slugrunner/runner.rb', line 31

def run
  Dir.mktmpdir do |tmpdir|
    logger("Scratch directory -> #{tmpdir}")
    @slug_dir = tmpdir
    @ping = true if !@ping_url.nil? && @ping_interval > 0
    download_and_run
    return 0
  end
rescue => e
  logger("Error: #{e}")
  return 1
end