Class: Deploy::Deployer

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/deploy/deployer.rb

Constant Summary collapse

DEPLOYED_DIR =
File.expand_path("~/.vendingmachine/control")
PIDFILE =
File.expand_path("~/.vendingmachine/pid")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(executable) ⇒ Deployer

Returns a new instance of Deployer.



14
15
16
17
18
# File 'lib/deploy/deployer.rb', line 14

def initialize(executable)
  @executable = executable
  @log = ""
  $: << DEPLOYED_DIR unless $:.include?(DEPLOYED_DIR)
end

Instance Attribute Details

#current_pidObject (readonly)

Returns the value of attribute current_pid.



12
13
14
# File 'lib/deploy/deployer.rb', line 12

def current_pid
  @current_pid
end

#executableObject (readonly)

Returns the value of attribute executable.



12
13
14
# File 'lib/deploy/deployer.rb', line 12

def executable
  @executable
end

Instance Method Details

#deploy(file_path) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/deploy/deployer.rb', line 24

def deploy(file_path)
  create_deployment_environment
  read_current_pid
  kill_running_process
  install_deployed_code(file_path)
  start_deployed_code
end

#killObject



32
33
34
35
36
# File 'lib/deploy/deployer.rb', line 32

def kill
  read_current_pid
  kill_running_process
  clear_current_pid
end

#run_logObject



20
21
22
# File 'lib/deploy/deployer.rb', line 20

def run_log
  @log
end

#wait_forObject



38
39
40
41
42
# File 'lib/deploy/deployer.rb', line 38

def wait_for
  Process.wait(read_current_pid)
  clear_current_pid
  self
end