Class: Puma::Redeploy::CommandRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/redeploy/command_runner.rb

Overview

Runs commands before redeploy process

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commands:, logger:, runner: Open3) ⇒ CommandRunner

Returns a new instance of CommandRunner.



11
12
13
14
15
# File 'lib/puma/redeploy/command_runner.rb', line 11

def initialize(commands:, logger:, runner: Open3)
  @logger = logger
  @commands = commands || []
  @runner = runner
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



9
10
11
# File 'lib/puma/redeploy/command_runner.rb', line 9

def commands
  @commands
end

#runnerObject (readonly)

Returns the value of attribute runner.



9
10
11
# File 'lib/puma/redeploy/command_runner.rb', line 9

def runner
  @runner
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
# File 'lib/puma/redeploy/command_runner.rb', line 17

def run
  commands.each do |command|
    @logger.info "running command: #{command}"
    stdout, stderr, status = runner.capture3(command)
    @logger.info "command stdout: #{stdout}"
    @logger.info "command status: #{status.exitstatus}"
    @logger.error "command stderr: #{stderr}" if status.exitstatus != 0
  end
end