Sha256: 44b519632f76c5b0cbc449c8866b61f277a4593877aae7bfcde4a3a07e8cee55

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require 'engineyard-serverside/callbacks/distributor/base'

require 'escape'

module EY
  module Serverside
    module Callbacks
      module Distributor
        module Ruby

          class Distributor < Base
            def distribute
              shell.status "Running deploy hook: #{hook}.rb"

              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

            private
            def escaped_command(hook)
              Escape.shell_command(command_for(hook.callback_name))
            end
            def command_for(hook_name)
              cmd = [
                About.binary,
                'hook', hook_name.to_s,
                '--app', config.app,
                '--environment-name', config.environment_name,
                '--account-name', config.account_name,
                '--release-path', paths.active_release.to_s,
                '--framework-env', config.framework_env.to_s
              ]

              cmd.push('--verbose') if config.verbose

              cmd
            end
          end

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
engineyard-serverside-2.7.0.pre lib/engineyard-serverside/callbacks/distributor/ruby/distributor.rb