Class: EY::Serverside::Callbacks::Distributor::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard-serverside/callbacks/distributor/remote.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner, hook) ⇒ Remote

Returns a new instance of Remote.



13
14
15
16
# File 'lib/engineyard-serverside/callbacks/distributor/remote.rb', line 13

def initialize(runner, hook)
  @runner = runner
  @hook = hook
end

Instance Attribute Details

#hookObject (readonly)

Returns the value of attribute hook.



7
8
9
# File 'lib/engineyard-serverside/callbacks/distributor/remote.rb', line 7

def hook
  @hook
end

#runnerObject (readonly)

Returns the value of attribute runner.



7
8
9
# File 'lib/engineyard-serverside/callbacks/distributor/remote.rb', line 7

def runner
  @runner
end

Class Method Details

.distribute(runner, hook) ⇒ Object



9
10
11
# File 'lib/engineyard-serverside/callbacks/distributor/remote.rb', line 9

def self.distribute(runner, hook)
  new(runner, hook).distribute
end

Instance Method Details

#distributeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/engineyard-serverside/callbacks/distributor/remote.rb', line 18

def distribute
  shell.status "Running deploy hook: #{hook}"

  runner.run escaped_command(hook) do |server, cmd|
    instance_args = [
      '--current-roles', server.roles.to_a.join(' ')
    ]

    if server.name
      instance_args.push('--current-name')
      instance_args.push(server.name.to_s)
    end

    instance_args.push('--config')
    instance_args.push(config.to_json)

    cmd << " " << Escape.shell_command(instance_args)
  end
end