Class: Gitlab::Housekeeper::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/housekeeper/shell.rb

Constant Summary collapse

Error =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.execute(*cmd) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/housekeeper/shell.rb', line 10

def self.execute(*cmd)
  stdin, stdout, stderr, wait_thr = Open3.popen3(*cmd)

  stdin.close
  out = stdout.read
  stdout.close
  err = stderr.read
  stderr.close

  exit_status = wait_thr.value

  raise Error, "Failed with #{exit_status}\n#{out}\n#{err}\n" unless exit_status.success?

  out + err
end